forked from Bush2021/chrome_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,673 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: [ | ||
{ name: windows_x86, os: windows-latest, arch: x86 }, | ||
{ name: windows_x64, os: windows-latest, arch: x64 }, | ||
] | ||
|
||
name: ${{ matrix.name }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: 'true' | ||
|
||
- name: setup VC-LTL | ||
if: matrix.os == 'windows-latest' | ||
working-directory: ${{env.GITHUB_WORKSPACE}} | ||
run: nuget install VC-LTL | ||
|
||
- name: setup xmake | ||
uses: xmake-io/github-action-setup-xmake@v1 | ||
|
||
- name: configure | ||
run: xmake f -a ${{ matrix.arch }} | ||
|
||
- name: build | ||
run: xmake | ||
|
||
- name: upload | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.name }} | ||
path: build/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.xmake/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "minhook"] | ||
path = minhook | ||
url = https://github.com/TsudaKageyu/minhook | ||
[submodule "mini_gzip"] | ||
path = mini_gzip | ||
url = https://github.com/shuax/mini_gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
# chrome_plus | ||
Chrome 增强软件 | ||
# 功能 | ||
- 双击关闭标签页 | ||
- 保留最后标签页(防止关闭最后一个标签页时关闭浏览器,点X不行) | ||
- 鼠标悬停标签栏滚动 | ||
- 按住右键时滚轮滚动标签栏 | ||
- 便携设计,程序放在App目录,数据放在Data目录(不兼容原版数据,可以重装系统换电脑不丢数据) | ||
- 移除更新错误警告(因为是绿色版没有自动更新功能) | ||
# 获取 | ||
采用GitHub Actions自动编译,请自行前往[编译](https://github.com/shuax/chrome_plus/actions)页面下载 | ||
[![build status](https://github.com/shuax/chrome_plus/actions/workflows/build.yml/badge.svg)](https://github.com/shuax/chrome_plus/actions/workflows/build.yml) | ||
# 安装 | ||
dll放入解压版Chrome目录即可 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
target("VC-LTL-5") | ||
set_kind("phony") | ||
before_build("windows", function (target) | ||
local function find_in_file() | ||
for _, dir in ipairs(os.dirs("$(projectdir)/*")) do | ||
name = dir:match(".*\\(.*)") | ||
if name:find("VC%-LTL") then | ||
return dir .. [[\build\native\]] | ||
end | ||
end | ||
end | ||
local function find_in_reg() | ||
return vformat("$(reg HKEY_CURRENT_USER\\Code\\VC-LTL;Root)") | ||
end | ||
local VC_LTL_Root = find_in_file() or find_in_reg() | ||
if #VC_LTL_Root==0 then | ||
return | ||
end | ||
local WindowsTargetPlatformMinVersion = "6.0.6000.0" | ||
cprint("${color.warning}VC-LTL Path : %s", VC_LTL_Root) | ||
cprint("${color.warning}WindowsTargetPlatformMinVersion : %s", WindowsTargetPlatformMinVersion) | ||
import("core.tool.toolchain") | ||
local msvc = toolchain.load("msvc") | ||
local runenvs = msvc:runenvs() | ||
|
||
local includepath = VC_LTL_Root .. [[TargetPlatform\header;]] .. VC_LTL_Root .. [[TargetPlatform\]] .. WindowsTargetPlatformMinVersion..[[\header;]] | ||
|
||
runenvs.INCLUDE = includepath .. runenvs.INCLUDE | ||
|
||
local arch = target:arch() | ||
local archpath = "Win32" | ||
if arch=="x86" then | ||
archpath = "Win32" | ||
elseif arch=="x64" then | ||
archpath = "x64" | ||
end | ||
cprint("${color.warning}Platform : %s", archpath) | ||
local libpath = VC_LTL_Root .. [[TargetPlatform\]] .. WindowsTargetPlatformMinVersion..[[\lib\]] .. archpath .. ";" | ||
|
||
runenvs.LIB = libpath .. runenvs.LIB | ||
|
||
-- print(runenvs.INCLUDE) | ||
-- print(runenvs.LIB) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
#pragma warning(disable: 4334) | ||
#pragma warning(disable: 4267) | ||
|
||
extern "C" | ||
{ | ||
#include "..\mini_gzip\miniz.c" | ||
#include "..\mini_gzip\mini_gzip.h" | ||
#include "..\mini_gzip\mini_gzip.c" | ||
} | ||
|
||
#pragma pack(push) | ||
#pragma pack(1) | ||
|
||
#define PACK4_FILE_VERSION (4) | ||
#define PACK5_FILE_VERSION (5) | ||
|
||
struct PAK4_HEADER | ||
{ | ||
uint32_t num_entries; | ||
uint8_t encodeing; | ||
}; | ||
|
||
struct PAK5_HEADER | ||
{ | ||
uint32_t encodeing; | ||
uint16_t resource_count; | ||
uint16_t alias_count; | ||
}; | ||
|
||
struct PAK_ENTRY | ||
{ | ||
uint16_t resource_id; | ||
uint32_t file_offset; | ||
}; | ||
|
||
struct PAK_ALIAS | ||
{ | ||
uint16_t resource_id; | ||
uint16_t entry_index; | ||
}; | ||
#pragma pack(pop) | ||
|
||
bool CheckHeader(uint8_t *buffer, PAK_ENTRY *&pak_entry, PAK_ENTRY *&end_entry) | ||
{ | ||
uint32_t version = *(uint32_t*)buffer; | ||
|
||
if (version != PACK4_FILE_VERSION && version != PACK5_FILE_VERSION) return false; | ||
|
||
if (version == PACK4_FILE_VERSION) | ||
{ | ||
PAK4_HEADER *pak_header = (PAK4_HEADER*)(buffer + sizeof(uint32_t)); | ||
if (pak_header->encodeing != 1) return false; | ||
|
||
pak_entry = (PAK_ENTRY*)(buffer + sizeof(uint32_t) + sizeof(PAK4_HEADER)); | ||
end_entry = pak_entry + pak_header->num_entries; | ||
} | ||
|
||
if (version == PACK5_FILE_VERSION) | ||
{ | ||
PAK5_HEADER *pak_header = (PAK5_HEADER*)(buffer + sizeof(uint32_t)); | ||
if (pak_header->encodeing != 1) return false; | ||
|
||
pak_entry = (PAK_ENTRY*)(buffer + sizeof(uint32_t) + sizeof(PAK5_HEADER)); | ||
end_entry = pak_entry + pak_header->resource_count; | ||
} | ||
|
||
// 为了保存最后一条的"下一条",这条特殊的条目的id一定为0 | ||
if (!end_entry || end_entry->resource_id != 0) return false; | ||
|
||
return true; | ||
} | ||
|
||
template<typename Function> | ||
void PakFind(uint8_t *buffer, uint8_t* pos, Function f) | ||
{ | ||
PAK_ENTRY *pak_entry = NULL; | ||
PAK_ENTRY *end_entry = NULL; | ||
|
||
// 检查文件头 | ||
if (!CheckHeader(buffer, pak_entry, end_entry)) return; | ||
|
||
do | ||
{ | ||
PAK_ENTRY *next_entry = pak_entry + 1; | ||
if (pos >= buffer + pak_entry->file_offset && pos <= buffer + next_entry->file_offset) | ||
{ | ||
f(buffer + pak_entry->file_offset, next_entry->file_offset - pak_entry->file_offset); | ||
break; | ||
} | ||
|
||
pak_entry = next_entry; | ||
} while (pak_entry->resource_id != 0); | ||
} | ||
|
||
template<typename Function> | ||
void TraversalGZIPFile(uint8_t *buffer, Function f) | ||
{ | ||
PAK_ENTRY *pak_entry = NULL; | ||
PAK_ENTRY *end_entry = NULL; | ||
|
||
// 检查文件头 | ||
if (!CheckHeader(buffer, pak_entry, end_entry)) return; | ||
|
||
do | ||
{ | ||
PAK_ENTRY *next_entry = pak_entry + 1; | ||
uint32_t old_size = next_entry->file_offset - pak_entry->file_offset; | ||
|
||
if (old_size < 10 * 1024) | ||
{ | ||
// 小于10k文件跳过 | ||
pak_entry = next_entry; | ||
continue; | ||
} | ||
|
||
BYTE gzip[] = { 0x1F, 0x8B, 0x08 }; | ||
size_t gzip_len = sizeof(gzip); | ||
if (memcmp(buffer + pak_entry->file_offset, gzip, gzip_len) != 0) | ||
{ | ||
// 不是gzip文件跳过 | ||
pak_entry = next_entry; | ||
continue; | ||
} | ||
|
||
uint32_t original_size = *(uint32_t*)(buffer + next_entry->file_offset - 4); | ||
uint8_t *unpack_buffer = (uint8_t *)malloc(original_size); | ||
if (!unpack_buffer) return; | ||
|
||
struct mini_gzip gz; | ||
mini_gz_start(&gz, buffer + pak_entry->file_offset, old_size); | ||
int unpack_len = mini_gz_unpack(&gz, unpack_buffer, original_size); | ||
|
||
if (original_size == unpack_len) | ||
{ | ||
uint32_t new_len = old_size; | ||
bool changed = f(unpack_buffer, unpack_len, new_len); | ||
if (changed) | ||
{ | ||
// 如果有改变 | ||
size_t compress_size = 0; | ||
uint8_t *compress_buffer = (uint8_t *)gzip_compress(unpack_buffer, new_len, &compress_size); | ||
if (compress_buffer && compress_size < old_size) | ||
{ | ||
/*FILE *fp = fopen("test.gz", "wb"); | ||
fwrite(compress_buffer, compress_size, 1, fp); | ||
fclose(fp);*/ | ||
|
||
//gzip头 | ||
memcpy(buffer + pak_entry->file_offset, compress_buffer, 10); | ||
|
||
//extra | ||
buffer[pak_entry->file_offset + 3] = 0x04; | ||
uint16_t extra_length = old_size - compress_size - 2; | ||
memcpy(buffer + pak_entry->file_offset + 10, &extra_length, sizeof(extra_length)); | ||
memset(buffer + pak_entry->file_offset + 12, '\0', extra_length); | ||
|
||
//compress | ||
memcpy(buffer + pak_entry->file_offset + 12 + extra_length, compress_buffer + 10, compress_size - 10); | ||
|
||
/*fp = fopen("test2.gz", "wb"); | ||
fwrite(buffer + pak_entry->file_offset, old_size, 1, fp); | ||
fclose(fp);*/ | ||
} | ||
else | ||
{ | ||
DebugLog(L"gzip compress error %d %d", compress_size, old_size); | ||
} | ||
|
||
if (compress_buffer) free(compress_buffer); | ||
} | ||
} | ||
|
||
free(unpack_buffer); | ||
pak_entry = next_entry; | ||
} while (pak_entry->resource_id != 0); | ||
} |
Oops, something went wrong.