├── .gitignore ├── LICENSE ├── README.md ├── README_EN.md ├── fast_github ├── .gitignore ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.cjs ├── src │ ├── assets │ │ └── icons │ │ │ ├── icon-128.png │ │ │ └── icon-34.png │ ├── background │ │ └── index.ts │ ├── content │ │ ├── index.ts │ │ └── style.css │ ├── manifest.json │ ├── options │ │ ├── Options.tsx │ │ ├── index.html │ │ ├── index.tsx │ │ └── style.css │ ├── popup │ │ ├── Popup.css │ │ ├── Popup.tsx │ │ ├── index.html │ │ └── index.tsx │ ├── test │ │ ├── download.svg │ │ └── test.ts │ ├── tools │ │ └── index.ts │ ├── types │ │ └── index.ts │ └── vite-env.d.ts ├── tailwind.config.cjs ├── tsconfig.json ├── vite.config.ts └── yarn.lock └── zip ├── v1.5.10.zip ├── v1.5.2.zip ├── v1.5.3.zip ├── v1.5.4.zip ├── v1.5.5.zip ├── v1.5.6.zip ├── v1.5.7.zip ├── v1.5.8.zip └── v1.5.9.zip /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/vscode,macos,node,git 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=vscode,macos,node,git 4 | 5 | ### Git ### 6 | # Created by git for backups. To disable backups in Git: 7 | # $ git config --global mergetool.keepBackup false 8 | *.orig 9 | 10 | # Created by git when using merge tools for conflicts 11 | *.BACKUP.* 12 | *.BASE.* 13 | *.LOCAL.* 14 | *.REMOTE.* 15 | *_BACKUP_*.txt 16 | *_BASE_*.txt 17 | *_LOCAL_*.txt 18 | *_REMOTE_*.txt 19 | 20 | ### macOS ### 21 | # General 22 | .DS_Store 23 | .AppleDouble 24 | .LSOverride 25 | 26 | # Icon must end with two \r 27 | Icon 28 | 29 | 30 | # Thumbnails 31 | ._* 32 | 33 | # Files that might appear in the root of a volume 34 | .DocumentRevisions-V100 35 | .fseventsd 36 | .Spotlight-V100 37 | .TemporaryItems 38 | .Trashes 39 | .VolumeIcon.icns 40 | .com.apple.timemachine.donotpresent 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | 49 | ### Node ### 50 | # Logs 51 | logs 52 | *.log 53 | npm-debug.log* 54 | yarn-debug.log* 55 | yarn-error.log* 56 | lerna-debug.log* 57 | 58 | # Diagnostic reports (https://nodejs.org/api/report.html) 59 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 60 | 61 | # Runtime data 62 | pids 63 | *.pid 64 | *.seed 65 | *.pid.lock 66 | 67 | # Directory for instrumented libs generated by jscoverage/JSCover 68 | lib-cov 69 | 70 | # Coverage directory used by tools like istanbul 71 | coverage 72 | *.lcov 73 | 74 | # nyc test coverage 75 | .nyc_output 76 | 77 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 78 | .grunt 79 | 80 | # Bower dependency directory (https://bower.io/) 81 | bower_components 82 | 83 | # node-waf configuration 84 | .lock-wscript 85 | 86 | # Compiled binary addons (https://nodejs.org/api/addons.html) 87 | build/Release 88 | 89 | # Dependency directories 90 | node_modules/ 91 | jspm_packages/ 92 | 93 | # TypeScript v1 declaration files 94 | typings/ 95 | 96 | # TypeScript cache 97 | *.tsbuildinfo 98 | 99 | # Optional npm cache directory 100 | .npm 101 | 102 | # Optional eslint cache 103 | .eslintcache 104 | 105 | # Optional stylelint cache 106 | .stylelintcache 107 | 108 | # Microbundle cache 109 | .rpt2_cache/ 110 | .rts2_cache_cjs/ 111 | .rts2_cache_es/ 112 | .rts2_cache_umd/ 113 | 114 | # Optional REPL history 115 | .node_repl_history 116 | 117 | # Output of 'npm pack' 118 | *.tgz 119 | 120 | # Yarn Integrity file 121 | .yarn-integrity 122 | 123 | # dotenv environment variables file 124 | .env 125 | .env.test 126 | .env*.local 127 | 128 | # parcel-bundler cache (https://parceljs.org/) 129 | .cache 130 | .parcel-cache 131 | 132 | # Next.js build output 133 | .next 134 | 135 | # Nuxt.js build / generate output 136 | .nuxt 137 | dist 138 | 139 | # Gatsby files 140 | .cache/ 141 | # Comment in the public line in if your project uses Gatsby and not Next.js 142 | # https://nextjs.org/blog/next-9-1#public-directory-support 143 | # public 144 | 145 | # vuepress build output 146 | .vuepress/dist 147 | 148 | # Serverless directories 149 | .serverless/ 150 | 151 | # FuseBox cache 152 | .fusebox/ 153 | 154 | # DynamoDB Local files 155 | .dynamodb/ 156 | 157 | # TernJS port file 158 | .tern-port 159 | 160 | # Stores VSCode versions used for testing VSCode extensions 161 | .vscode-test 162 | 163 | ### vscode ### 164 | .vscode/* 165 | !.vscode/settings.json 166 | !.vscode/tasks.json 167 | !.vscode/launch.json 168 | !.vscode/extensions.json 169 | *.code-workspace 170 | 171 | # End of https://www.toptal.com/developers/gitignore/api/vscode,macos,node,git -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Powered by DartNode](https://dartnode.com/branding/DN-Open-Source-sm.png)](https://dartnode.com "Powered by DartNode - Free VPS for Open Source") 2 | 3 | # FAST-GitHub 4 | 5 | # 简介 6 | 7 | 国内 Github 下载很慢,用上了这个插件后,下载速度嗖嗖嗖的~! 8 | 9 | [![Page Views Count](https://badges.toozhao.com/badges/01EH1R0YMQANV1ACQXTEBK7JCN/green.svg)](https://badges.toozhao.com/badges/01EH1R0YMQANV1ACQXTEBK7JCN/green.svg "Get your own page views count badge on badges.toozhao.com") 10 | 11 | # 支持 12 | 由Cloudflare提供强力支持 13 | 14 | 15 | # 下载插件 16 | 17 | 感谢大家一直以来的支持 18 | 19 | **GitHub加速**已从Chrome商店下架 20 | 21 | 原因: 22 | 23 | 1. Chrome商店的使用人数在逐渐减少 24 | 2. 现在已经有了更好加速GitHub访问、下载的工具和方法 25 | 26 | ![CleanShot 2024-02-17 at 13 07 23@2x](https://github.com/fhefh2015/Fast-GitHub/assets/14891797/a8100c4a-6796-4f56-b609-5fca668d1145) 27 | 28 | 29 | **GitHub加速**已从苹果商店下架 30 | 31 | 原因: 32 | 33 | 1. 朋友转行、账号快到期 34 | 2. 插件收益 < 苹果开发者费用($99) 35 | 36 | 感谢购买macOS版本插件的朋友 37 | 38 | 39 | 40 | 41 | 42 | 47 | 48 | 49 |
43 | 44 | 45 | 46 |
50 | 51 | # 预览 52 | 53 | CleanShot 2022-02-14 at 14 55 25@2x 54 | 55 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | # Fast-GitHub 2 | 3 | ![Chrome Web Store](https://img.shields.io/chrome-web-store/v/mfnkflidjnladnkldfonnaicljppahpg?style=for-the-badge) 4 | ![Chrome Web Store](https://img.shields.io/chrome-web-store/users/mfnkflidjnladnkldfonnaicljppahpg?style=for-the-badge) 5 | 6 | 7 | 8 | # INTRODUCTION 9 | 10 | Github download speeds are generally slow in Asia, and with this plugin the download speeds will be insane! 11 | 12 | [![Page Views Count](https://badges.toozhao.com/badges/01EH1R0YMQANV1ACQXTEBK7JCN/green.svg)](https://badges.toozhao.com/badges/01EH1R0YMQANV1ACQXTEBK7JCN/green.svg "Get your own page views count badge on badges.toozhao.com") 13 | 14 | # Support 15 | Power By Cloudflare 16 | 17 | # Download 18 | 19 | 20 | 21 | 22 | 27 | 30 | 35 | 38 | 39 | 40 |
23 | 24 | 25 | 26 | 28 | 29 | 31 | 32 | 33 | 34 | 36 | 37 |
41 | 42 | # Preview 43 | 44 | ![MNOt8347RDGmnjo](https://i.loli.net/2021/04/23/MNOt8347RDGmnjo.png) 45 | 46 | ![9UPXkGsHzw5hiru](https://i.loli.net/2021/04/23/9UPXkGsHzw5hiru.png) 47 | 48 | 49 | # How to use SSH channels 50 | 51 | Configuring user profiles (`~/.ssh/config`) 52 | 53 | ```bash 54 | Host github.com 55 | HostName github.com 56 | User git 57 | IdentityFile Specify the path to the private key file used for key authentication 58 | # Add the following 59 | Host git.zhlh6.cn 60 | HostName git.zhlh6.cn 61 | User git 62 | IdentityFile Using the secret key of github.com 63 | ``` 64 | 65 | Testing SSH Connections 66 | 67 | ```bash 68 | ssh -T git@git.zhlh6.cn 69 | 70 | # successful 71 | You've successfully authenticated, but GitHub does not provide shell access 72 | ``` 73 | 74 | --- 75 | -------------------------------------------------------------------------------- /fast_github/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /fast_github/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fast_github/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "translation-machine", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "cross-env NODE_ENV=production && tsc && vite build --watch", 8 | "dev:firefox": "yarn install && tsc && TARGET=firefox vite dev", 9 | "build": "cross-env NODE_ENV=production && tsc && vite build", 10 | "build:firefox": "yarn install && tsc && TARGET=firefox vite build", 11 | "validate": "web-ext lint -s dist" 12 | }, 13 | "resolutions": { 14 | "react-error-overlay": "6.0.9" 15 | }, 16 | "devDependencies": { 17 | "@types/chrome": "^0.0.200", 18 | "@types/file-saver": "^2.0.5", 19 | "@types/react-dom": "^18.0.8", 20 | "@vitejs/plugin-react": "^2.2.0", 21 | "autoprefixer": "^10.4.13", 22 | "cross-env": "^7.0.3", 23 | "postcss": "^8.4.19", 24 | "react": "^18.2.0", 25 | "react-dom": "^18.2.0", 26 | "react-error-overlay": "6.0.9", 27 | "tailwindcss": "^3.2.3", 28 | "typescript": "^4.6.4", 29 | "vite": "^3.2.0", 30 | "vite-plugin-web-extension": "1.4.4" 31 | }, 32 | "dependencies": { 33 | "@types/react": "^18.0.24", 34 | "file-saver": "^2.0.5", 35 | "terser": "^5.15.1" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fast_github/postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /fast_github/src/assets/icons/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/fast_github/src/assets/icons/icon-128.png -------------------------------------------------------------------------------- /fast_github/src/assets/icons/icon-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/fast_github/src/assets/icons/icon-34.png -------------------------------------------------------------------------------- /fast_github/src/background/index.ts: -------------------------------------------------------------------------------- 1 | import { getLocalItem, translateByTencent } from "../tools"; 2 | import { ResponseData, ResponseError, RuntimeSendMessageType } from "../types"; 3 | 4 | chrome.runtime.onInstalled.addListener((details) => { 5 | const { reason } = details; 6 | 7 | if (reason === "install") { 8 | chrome.runtime.openOptionsPage(); 9 | return; 10 | } 11 | 12 | getLocalItem().then((configs) => { 13 | if (!configs.importOldList) { 14 | if (reason === "update") { 15 | chrome.runtime.openOptionsPage(); 16 | } 17 | } 18 | }); 19 | }); 20 | 21 | type SendResponseMessageType = [ResponseData, ResponseError]; 22 | 23 | chrome.runtime.onMessage.addListener((message, _, sendResponse) => { 24 | const data = message as RuntimeSendMessageType; 25 | const content = data.content; 26 | 27 | const sendResponseMessage = (dataObject: SendResponseMessageType) => { 28 | console.log("content: ", content); 29 | const [data, error] = dataObject; 30 | let sendMessageObject: RuntimeSendMessageType = { content: "" }; 31 | 32 | if (data) { 33 | sendMessageObject.content = data; 34 | } 35 | 36 | if (error) { 37 | sendMessageObject.content = error; 38 | } 39 | 40 | sendResponse(sendMessageObject); 41 | }; 42 | 43 | translateByTencent(content).then((responseData) => { 44 | sendResponseMessage(responseData); 45 | }); 46 | return true; 47 | }); 48 | 49 | // (async () => { 50 | // translateByTencent("hello").then((responseData) => { 51 | // console.log("data: ", responseData); 52 | // }); 53 | // })(); 54 | 55 | // chrome.webNavigation.onHistoryStateUpdated.addListener( 56 | // (details) => { 57 | // console.log(`onHistoryStateUpdated: ${details.url}`); 58 | 59 | // if (details.url.includes("github.com")) { 60 | // const message: MessageType = { 61 | // status: "complete", 62 | // url: details.url, 63 | // }; 64 | 65 | // chrome.tabs.sendMessage(details.tabId, message); 66 | // } 67 | 68 | // console.log(`Transition type: ${details.transitionType}`); 69 | // console.log(`Transition qualifiers: ${details.transitionQualifiers}`); 70 | // }, 71 | // { 72 | // url: [{ hostContains: "github.com" }], 73 | // } 74 | // ); 75 | 76 | // chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { 77 | // if (tab.status === "complete" && tab.url && tab.url.includes("github.com")) { 78 | // const message: MessageType = { 79 | // status: "complete", 80 | // url: tab.url, 81 | // }; 82 | // chrome.tabs.sendMessage(tabId, message); 83 | // } 84 | // }); 85 | -------------------------------------------------------------------------------- /fast_github/src/content/index.ts: -------------------------------------------------------------------------------- 1 | import { saveAs } from "file-saver"; 2 | import { 3 | checkSelector, 4 | getLocalItem, 5 | randomUniqueNumbers, 6 | translateElem, 7 | } from "../tools"; 8 | import { PageTypeItemValue } from "../types"; 9 | import "./style.css"; 10 | 11 | const main = async () => { 12 | const speedButtonId = "fast_github"; 13 | 14 | const urlInfo = new URL(window.location.href); 15 | const urlPath = urlInfo.pathname.split("/").slice(1, 5); 16 | 17 | const configs = await await getLocalItem(); 18 | const defaultList = configs.speedList.split("\n"); 19 | const speedNumber = configs.speedNumber; 20 | 21 | const my_github_url = urlInfo.origin; 22 | const [my_github_author, my_github_project, pageType] = urlPath; 23 | // const my_github_project_git = `${my_github_project}.git`; 24 | const my_github_project_url = `${my_github_url}/${my_github_author}/${my_github_project}`; 25 | 26 | if (!my_github_author && !my_github_project) { 27 | return; 28 | } 29 | 30 | const checkPrivateProject = () => { 31 | const spanList = document.querySelectorAll("span.Label--secondary"); 32 | 33 | console.log("checkPrivateProject: ", spanList); 34 | 35 | const [item] = Array.from(spanList).filter((item) => { 36 | return item.textContent?.trim() === "Private"; 37 | }); 38 | 39 | return item ? true : false; 40 | }; 41 | 42 | const getMainOrMasterURL = (): string | null => { 43 | const elemList = document.querySelectorAll(".Box-row a"); 44 | 45 | const [result] = Array.from(elemList).filter((elem) => { 46 | return elem.textContent?.trim().includes("Download ZIP"); 47 | }); 48 | 49 | return result?.getAttribute("href") ?? null; 50 | }; 51 | 52 | const addIDEButton = () => { 53 | const rowList = document.querySelectorAll( 54 | 'div.js-active-navigation-container div.js-navigation-item[role="row"]' 55 | ); 56 | const id = "add-my-github-ide"; 57 | const buttonId = "my-github-ide-button"; 58 | 59 | console.log("js-active-navigation-container: ", rowList); 60 | 61 | if (!rowList) { 62 | return; 63 | } 64 | 65 | rowList.forEach((item) => { 66 | if (item.classList.contains(id)) { 67 | return; 68 | } 69 | 70 | const headerDiv = item.querySelector('div[role="rowheader"] a'); 71 | 72 | if ( 73 | headerDiv 74 | ?.getAttribute("title") 75 | ?.trim() 76 | .includes("Go to parent directory") 77 | ) { 78 | return; 79 | } 80 | 81 | item.classList.add(id); 82 | 83 | const urlList = item.querySelectorAll("a"); 84 | const [urlItem] = Array.from(urlList).filter((item) => { 85 | return !item 86 | .getAttribute("href") 87 | ?.includes(`/${my_github_project}/commit/`); 88 | }); 89 | 90 | console.log("urlItem: ", urlItem); 91 | 92 | if (!urlItem) { 93 | return; 94 | } 95 | 96 | const href = urlItem.getAttribute("href"); 97 | 98 | if (!href) { 99 | return; 100 | } 101 | 102 | const webIDE = configs.webIDE; 103 | 104 | if (!webIDE) { 105 | return; 106 | } 107 | 108 | if (webIDE === "Nothing") { 109 | return; 110 | } 111 | 112 | const template = ` 113 | 116 | 117 | 118 | `; 119 | item.insertAdjacentHTML("beforeend", template); 120 | 121 | if ( 122 | item 123 | .querySelector("svg.octicon") 124 | ?.getAttribute("aria-label") 125 | ?.trim() !== "File" 126 | ) { 127 | return; 128 | } 129 | 130 | // 添加下载按钮 131 | const rawURL = href.replace("/blob/", "/"); 132 | const [downloadFileName] = href.split("/").slice(-1); 133 | 134 | const downloadIconTemplate = ` 135 |
136 | 137 | 138 | 139 | 144 |
145 | `; 146 | 147 | item.insertAdjacentHTML("beforeend", downloadIconTemplate); 148 | 149 | item.querySelector(".download_file")?.addEventListener( 150 | "click", 151 | (e) => { 152 | e.preventDefault(); 153 | const target = e.currentTarget as HTMLElement; 154 | console.log("downloadFile123: ", target); 155 | 156 | if (target.getAttribute("data-download") === "true") { 157 | alert("正在下载中..."); 158 | return; 159 | } 160 | 161 | target.setAttribute("data-download", "true"); 162 | 163 | const downloadIconElem = target.querySelector( 164 | ".download-icon" 165 | ) as HTMLElement; 166 | const loadingIconElem = target.querySelector( 167 | ".loading-icon" 168 | ) as HTMLElement; 169 | 170 | downloadIconElem.style.display = "none"; 171 | loadingIconElem.style.display = "block"; 172 | 173 | const random = randomUniqueNumbers(defaultList.length, 1)[0]; 174 | const url = defaultList[random - 1]; 175 | const cf_url = url.endsWith("/") ? url : `${url}/`; 176 | const downloadURL = `${cf_url}https://raw.githubusercontent.com${rawURL}`; 177 | 178 | fetch(downloadURL) 179 | .then((response) => response.blob()) 180 | .then(function (data) { 181 | console.log("fetch: ", data); 182 | 183 | saveAs(data, downloadFileName); 184 | 185 | downloadIconElem.style.display = "block"; 186 | loadingIconElem.style.display = "none"; 187 | target.setAttribute("data-download", "false"); 188 | }) 189 | .catch((e: Error) => { 190 | alert(e.message); 191 | target.setAttribute("data-download", "false"); 192 | downloadIconElem.style.display = "block"; 193 | loadingIconElem.style.display = "none"; 194 | }); 195 | }, 196 | false 197 | ); 198 | }); 199 | }; 200 | 201 | const mainPage = async () => { 202 | console.log("mainPage"); 203 | const addSpeedButton = () => { 204 | if (document.querySelector(`#${speedButtonId}`)) { 205 | return; 206 | } 207 | 208 | let listTemplate = ""; 209 | const list = defaultList; 210 | 211 | const rangeNumber = randomUniqueNumbers(list.length, speedNumber); 212 | 213 | rangeNumber.map((index) => { 214 | const item = list[index - 1]; 215 | const url = item.endsWith("/") ? item : `${item}/`; 216 | const urlInfo = new URL(url); 217 | 218 | listTemplate += ` 219 |
220 |

221 | ${urlInfo.host}通道 222 |

223 |
224 | 225 |
226 | 227 | 233 | 234 |
235 |
236 |
237 | `; 238 | }); 239 | 240 | const template = ` 241 |
242 | 243 | 加速 244 | 245 | 246 |
247 | 263 |
264 |
265 |
`; 266 | const insertElem = document.querySelector(".file-navigation"); 267 | 268 | insertElem?.insertAdjacentHTML("beforeend", template); 269 | 270 | try { 271 | const downloadBtn = document.getElementById("downloadZIP"); 272 | 273 | downloadBtn?.addEventListener( 274 | "click", 275 | function () { 276 | // const fileName = `${my_github_project}.zip`; 277 | const href = getMainOrMasterURL(); 278 | if (!href) { 279 | alert("无法获取压缩包下载地址"); 280 | return; 281 | } 282 | 283 | const random = randomUniqueNumbers(defaultList.length, 1)[0]; 284 | const cf_url = defaultList[random - 1]; 285 | const src = `${cf_url}/https://github.com${href}`; 286 | 287 | window.location.href = src; 288 | }, 289 | false 290 | ); 291 | 292 | const infoURL = "https://yidian.one/chrome/info.json"; 293 | fetch(infoURL) 294 | .then((response) => response.json()) 295 | .then((data) => { 296 | type DataType = { 297 | url: string; 298 | title: string; 299 | desc: string; 300 | code: string; 301 | color: string; 302 | }; 303 | const { url, title, desc, code, color } = data as DataType; 304 | if (parseInt(code)) { 305 | const infoTemplate = `${title}`; 306 | 307 | const elem = document.getElementById("info-wrap"); 308 | 309 | if (elem?.querySelector("#my-notice")) { 310 | return; 311 | } 312 | 313 | elem?.insertAdjacentHTML("beforeend", infoTemplate); 314 | } 315 | }) 316 | .catch(() => console.log("Oops, fetch error")); 317 | } catch (e) { 318 | console.log("Oops, error: ", e); 319 | } 320 | }; 321 | 322 | addSpeedButton(); 323 | }; 324 | 325 | const releasesPage = (elem?: HTMLElement) => { 326 | const liList = elem 327 | ? checkSelector(elem) 328 | ? elem.querySelectorAll("li.Box-row") 329 | : document.querySelectorAll("li.Box-row") 330 | : document.querySelectorAll("li.Box-row"); 331 | 332 | const myElem = elem as HTMLElement; 333 | const id = "my-fast-github"; 334 | 335 | if (!liList) { 336 | return; 337 | } 338 | 339 | liList.forEach((item) => { 340 | if (item.classList.contains(id)) { 341 | return; 342 | } 343 | 344 | const href = item.querySelector("a")?.getAttribute("href"); 345 | 346 | if (!href) { 347 | return; 348 | } 349 | 350 | item.classList.add(id); 351 | 352 | const rangeNumber = randomUniqueNumbers(defaultList.length, 1); 353 | const url = defaultList[rangeNumber[0] - 1]; 354 | const itemURL = url.endsWith("/") ? url : `${url}/`; 355 | const divTemplate = ` 356 |
357 | 358 | 359 | 360 | 下载 361 | 362 | 363 |
364 | `; 365 | 366 | item.insertAdjacentHTML("beforeend", divTemplate); 367 | }); 368 | }; 369 | 370 | const tagPage = (elem?: HTMLElement) => { 371 | const list = elem 372 | ? checkSelector(elem) 373 | ? elem.querySelectorAll("div.commit") 374 | : document.querySelectorAll("div.commit") 375 | : document.querySelectorAll("div.commit"); 376 | 377 | const id = "my-fast-github"; 378 | 379 | if (!list) { 380 | return; 381 | } 382 | 383 | list.forEach((item) => { 384 | const liList = item.querySelectorAll("ul>li.d-inline-block"); 385 | 386 | if (!liList) { 387 | return; 388 | } 389 | 390 | liList.forEach((liItem) => { 391 | console.log("liItem: ", liItem); 392 | if (liItem.classList.contains(id)) { 393 | return; 394 | } 395 | 396 | const zipElem = liItem.querySelector("a"); 397 | const zip_href = zipElem?.getAttribute("href"); 398 | 399 | console.log("zip_href: ", zip_href, zip_href?.includes(".zip")); 400 | 401 | if (zip_href?.endsWith(".tar.gz") || zip_href?.endsWith(".zip")) { 402 | liItem.classList.add(id); 403 | 404 | const zip_text = zipElem?.textContent; 405 | const rangeNumber = randomUniqueNumbers(defaultList.length, 1); 406 | const url = defaultList[rangeNumber[0] - 1]; 407 | console.log("url: ", url); 408 | const itemURL = url.endsWith("/") ? url : `${url}/`; 409 | const zip_template = ` 410 | 411 | 412 | 加速${zip_text} 413 | 414 | `; 415 | liItem.insertAdjacentHTML("beforeend", zip_template); 416 | } 417 | }); 418 | }); 419 | }; 420 | 421 | const issuesPage = () => { 422 | if (configs.language === "nothing" || configs.token?.trim() === "") { 423 | return; 424 | } 425 | 426 | const issuesLists = document.querySelectorAll( 427 | ".edit-comment-hide table.user-select-contain tr.d-block>td" 428 | ); 429 | 430 | if (!issuesLists) { 431 | return; 432 | } 433 | 434 | issuesLists.forEach((item) => { 435 | const button = item.parentNode?.querySelector( 436 | ".issues-translation-button" 437 | ); 438 | 439 | if (button) { 440 | return; 441 | } 442 | 443 | const clickButton = document.createElement("div"); 444 | clickButton.textContent = "翻译"; 445 | clickButton.className = "issues-translation-button"; 446 | 447 | clickButton.style.cssText = 448 | "font-size: 15px;cursor: pointer;color: rgb(29, 155, 240);padding: 0px 16px;margin-bottom:10px;text-align:right;"; 449 | 450 | item.after(clickButton); 451 | 452 | clickButton.addEventListener( 453 | "click", 454 | async (e) => { 455 | e.preventDefault(); 456 | 457 | const cloneElem = item.cloneNode(true) as HTMLElement; 458 | const contentElem = item.parentNode?.querySelector( 459 | ".issues-translation-content" 460 | ); 461 | 462 | if (contentElem) { 463 | contentElem.remove(); 464 | } 465 | 466 | cloneElem.classList.add("issues-translation-content"); 467 | cloneElem.style.cssText = "display:block;margin-top:10px;"; 468 | 469 | translateElem(cloneElem); 470 | 471 | clickButton.after(cloneElem); 472 | 473 | return; 474 | }, 475 | false 476 | ); 477 | }); 478 | }; 479 | 480 | if (my_github_author && my_github_project) { 481 | // 个人私有项目 按钮不添加 482 | if (checkPrivateProject()) { 483 | return; 484 | } 485 | 486 | const myPageType = pageType as PageTypeItemValue; 487 | if (myPageType === undefined) { 488 | // 项目首页 https://github.com/torvalds/linux 489 | mainPage(); 490 | addIDEButton(); 491 | console.log("getMainOrMasterURL main: ", getMainOrMasterURL()); 492 | } 493 | 494 | if (myPageType === "tree") { 495 | addIDEButton(); 496 | 497 | // 项目分支 https://github.com/GameServerManagers/LinuxGSM/tree/develop/lgsm 498 | if (!getMainOrMasterURL()) { 499 | return; 500 | } 501 | 502 | mainPage(); 503 | 504 | console.log("getMainOrMasterURL tree: ", getMainOrMasterURL()); 505 | } 506 | 507 | if (myPageType === "releases") { 508 | console.log("release"); 509 | // release页面 https://github.com/GameServerManagers/LinuxGSM/releases 510 | releasesPage(); 511 | } 512 | 513 | if (myPageType === "tags") { 514 | // tag页面 https://github.com/torvalds/linux/tags 515 | tagPage(); 516 | } 517 | 518 | if (myPageType === "issues") { 519 | issuesPage(); 520 | } 521 | } 522 | }; 523 | 524 | // 监听Github URL的变化 因为ta用了Pjax刷新 525 | const observer = new MutationObserver(function (mutations) { 526 | console.log("c3"); 527 | main(); 528 | }); 529 | 530 | observer.observe(document, { 531 | childList: true, 532 | subtree: true, 533 | }); 534 | 535 | // if (!chrome.runtime.onMessage.hasListeners()) { 536 | // chrome.runtime.onMessage.addListener(function ( 537 | // request, 538 | // sender, 539 | // sendResponse 540 | // ) { 541 | // // 监听Github URL的变化 因为ta用了Pjax刷新 542 | // const message: MessageType = request; 543 | // console.log("c0"); 544 | // if (message.status === "complete") { 545 | // console.log("c1"); 546 | // main(); 547 | // } 548 | // }); 549 | // } 550 | -------------------------------------------------------------------------------- /fast_github/src/content/style.css: -------------------------------------------------------------------------------- 1 | .fast-github-hide { 2 | display: none !important; 3 | } 4 | 5 | .fast-github-show { 6 | display: none !important; 7 | } 8 | -------------------------------------------------------------------------------- /fast_github/src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 3, 3 | "name": "GitHub加速", 4 | "description": "国内Github下载很慢,用上了这个插件后,下载速度嗖嗖嗖的~!’", 5 | "version": "1.5.10", 6 | "options_page": "options/index.html", 7 | "background": { 8 | "service_worker": "background/index.ts" 9 | }, 10 | "icons": { 11 | "128": "assets/icons/icon-128.png" 12 | }, 13 | "content_scripts": [ 14 | { 15 | "matches": [ 16 | "*://github.com/*" 17 | ], 18 | "js": [ 19 | "content/index.ts" 20 | ], 21 | "css": [] 22 | } 23 | ], 24 | "permissions": [ 25 | "storage" 26 | ] 27 | } -------------------------------------------------------------------------------- /fast_github/src/options/Options.tsx: -------------------------------------------------------------------------------- 1 | import React, { ChangeEvent, useEffect, useState } from "react"; 2 | import { getLocalItem, getOldVersionLocalItem, saveLocalItem } from "../tools"; 3 | import { 4 | DefaultConfig, 5 | defaultConfigs, 6 | FieldTypeKey, 7 | onlySupportSelect, 8 | WebIDEItemValue, 9 | } from "../types"; 10 | import "./style.css"; 11 | 12 | const Options: React.FC = () => { 13 | const webIDEItems: WebIDEItemValue[] = [ 14 | "Nothing", 15 | "GitHub.Dev", 16 | "GitHub1s.Com", 17 | ]; 18 | 19 | const [configs, setConfigs] = useState(defaultConfigs); 20 | 21 | const handleChange = ( 22 | type: FieldTypeKey, 23 | e: ChangeEvent 24 | ) => { 25 | const value = e.target.value; 26 | console.log("value: ", value); 27 | const saveConfigs = Object.assign({}, configs, { [type]: value }); 28 | setConfigs(saveConfigs); 29 | }; 30 | 31 | const handleSave = () => { 32 | const listNumber = configs.speedList 33 | .replace(/(\n)+/g, "\n") 34 | .replace(/\n+$/, "") 35 | .split("\n").length; 36 | 37 | const saveConfigs = Object.assign({}, configs, { 38 | speedNumber: 39 | configs.speedNumber > listNumber ? listNumber : configs.speedNumber, 40 | speedList: configs.speedList.replace(/(\n)+/g, "\n").replace(/\n+$/, ""), 41 | importOldList: true, 42 | }); 43 | 44 | setConfigs(saveConfigs); 45 | saveLocalItem(saveConfigs); 46 | 47 | alert("设置已保存"); 48 | }; 49 | 50 | useEffect(() => { 51 | document.title = "设置"; 52 | 53 | const getConfigs = async () => { 54 | const configs = (await getLocalItem()) as DefaultConfig; 55 | const oldConfigs = await getOldVersionLocalItem(); 56 | 57 | if (configs) { 58 | if (!configs.importOldList) { 59 | // v1.5之前的数据导入 60 | if (oldConfigs && oldConfigs.length) { 61 | try { 62 | const oldWithDefault: DefaultConfig = { 63 | importOldList: true, 64 | speedNumber: defaultConfigs.speedNumber, 65 | speedList: oldConfigs 66 | .join("\n") 67 | .replace(/\n+$/, "") 68 | .replace(/github_proxy/g, ""), 69 | }; 70 | setConfigs(oldWithDefault); 71 | } catch (e) { 72 | setConfigs(configs); 73 | } 74 | } else { 75 | setConfigs(configs); 76 | } 77 | } else { 78 | setConfigs(configs); 79 | } 80 | } 81 | }; 82 | 83 | getConfigs(); 84 | }, []); 85 | 86 | return ( 87 | <> 88 | {configs && ( 89 |
90 |
91 |
92 |
93 | 99 | handleChange("speedNumber", e)} 104 | value={configs.speedNumber} 105 | /> 106 |
107 |
108 | 114 | handleChange("token", e)} 119 | value={configs.token} 120 | placeholder="请填写Token,才能使用" 121 | /> 122 |
123 |
124 | 135 | 155 |
156 | 157 |
158 | 164 | 184 |
185 | 查看源码使用的Web IDE,默认使用GitHub1s 186 |
187 |
188 | 关于GitHub1s: 189 | 194 | 点击查看 195 | 196 |
197 |
198 | 199 |
200 | 206 | 214 |
215 | 216 |
217 |
218 | 如果您不想做任何操作,也请点击一下保存配置。 219 |
220 |
221 | 如果没有看到v1.5以前的加速列表,请重新添加并保存。 222 |
223 |
224 | 自行搭建加速教程: 225 | 230 | 点击查看 231 | 232 |
233 |
234 | 如何使用: 235 | 240 | 点击查看 241 | 242 |
243 |
244 | 245 |
246 | 252 |
253 |
254 |
255 |
256 | )} 257 | 258 | ); 259 | }; 260 | 261 | export default Options; 262 | -------------------------------------------------------------------------------- /fast_github/src/options/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Options 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fast_github/src/options/index.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from "react-dom/client"; 2 | import Options from "./Options"; 3 | 4 | function init() { 5 | const appContainer = document.querySelector("#app"); 6 | if (!appContainer) { 7 | throw new Error("Can not find AppContainer"); 8 | } 9 | const root = createRoot(appContainer); 10 | root.render(); 11 | } 12 | 13 | init(); 14 | -------------------------------------------------------------------------------- /fast_github/src/options/style.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | background-color: rgba(237, 242, 247, 1); 7 | padding: 30px 0; 8 | } 9 | -------------------------------------------------------------------------------- /fast_github/src/popup/Popup.css: -------------------------------------------------------------------------------- 1 | .pop { 2 | width: 300px; 3 | height: 500px; 4 | background-color: #a3c7d6; 5 | font-size: 20px; 6 | text-align: center; 7 | line-height: 100%; 8 | } 9 | -------------------------------------------------------------------------------- /fast_github/src/popup/Popup.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import "./Popup.css"; 3 | 4 | const Popup: React.FC = () => { 5 | return
Popup
; 6 | }; 7 | 8 | export default Popup; 9 | -------------------------------------------------------------------------------- /fast_github/src/popup/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Popup 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fast_github/src/popup/index.tsx: -------------------------------------------------------------------------------- 1 | import { createRoot } from "react-dom/client"; 2 | import Popup from "./Popup"; 3 | 4 | function init() { 5 | const appContainer = document.querySelector("#app"); 6 | if (!appContainer) { 7 | throw new Error("Can not find AppContainer"); 8 | } 9 | const root = createRoot(appContainer); 10 | root.render(); 11 | } 12 | 13 | init(); 14 | -------------------------------------------------------------------------------- /fast_github/src/test/download.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fast_github/src/test/test.ts: -------------------------------------------------------------------------------- 1 | type RangeScopeType = [start: number, end: number]; 2 | const randomUniqueNumbers = (range: RangeScopeType, count: number) => { 3 | const [start, end] = range; 4 | 5 | if (start > end) { 6 | return []; 7 | } 8 | 9 | const maxCount = end - start - 1; 10 | let numberContainer = new Set(); 11 | const useCount = count >= maxCount ? maxCount : count; 12 | 13 | while (numberContainer.size < useCount) { 14 | numberContainer.add(Math.floor(Math.random() * (start - end + 1) + end)); 15 | } 16 | return [...numberContainer].sort(); 17 | }; 18 | 19 | const result = randomUniqueNumbers([1, 10], 2); 20 | 21 | console.log(result); 22 | -------------------------------------------------------------------------------- /fast_github/src/tools/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DefaultConfig, 3 | defaultConfigs, 4 | LangDetectObject, 5 | languageData, 6 | ResponseData, 7 | ResponseError, 8 | RuntimeSendMessageType, 9 | TranslationBlockObject, 10 | } from "../types"; 11 | 12 | export const saveLocalItem = (object: DefaultConfig) => { 13 | chrome.storage.sync.set({ configs: object }); 14 | }; 15 | 16 | export const getLocalItem = async () => { 17 | const result = await chrome.storage.sync.get("configs"); 18 | return (result["configs"] as DefaultConfig) ?? defaultConfigs; 19 | }; 20 | 21 | export const randomUniqueNumbers = (range: number, count: number) => { 22 | let numberContainer = new Set(); 23 | while (numberContainer.size < count) { 24 | numberContainer.add(Math.floor(Math.random() * (range - 1 + 1) + 1)); 25 | } 26 | return [...numberContainer]; 27 | }; 28 | 29 | export const checkSelector = (elem: HTMLElement): boolean => { 30 | return elem.querySelectorAll instanceof Function; 31 | }; 32 | 33 | export const getOldVersionLocalItem = async () => { 34 | const result = await chrome.storage.sync.get("customList"); 35 | return (result["customList"] as string[]) ?? []; 36 | }; 37 | 38 | export const translateElem = async ( 39 | rootElem: HTMLElement, 40 | elemName: string = "" 41 | ) => { 42 | if (!rootElem) { 43 | return; 44 | } 45 | 46 | if (rootElem.nodeType === 1) { 47 | rootElem.childNodes.forEach((item) => { 48 | const myItem = item as HTMLElement; 49 | const nodeName = item.nodeName.toLowerCase(); 50 | 51 | if ( 52 | nodeName === "pre" || 53 | nodeName === "code" || 54 | nodeName === "video" || 55 | nodeName === "img" || 56 | nodeName === "input" || 57 | nodeName === "select" || 58 | nodeName === "g-emoji" 59 | ) { 60 | return; 61 | } 62 | 63 | translateElem(myItem, nodeName); 64 | }); 65 | } 66 | 67 | if (rootElem.nodeType === 3) { 68 | if (elemName == "" || elemName === "pre" || elemName === "code") { 69 | return; 70 | } 71 | 72 | const content = rootElem.nodeValue ?? ""; 73 | 74 | if (!content.length) { 75 | return; 76 | } 77 | 78 | const sendMessage: RuntimeSendMessageType = { 79 | content: content, 80 | }; 81 | 82 | const data: RuntimeSendMessageType = await chrome.runtime.sendMessage( 83 | sendMessage 84 | ); 85 | 86 | if (data.content) { 87 | rootElem.textContent = data.content; 88 | } 89 | } 90 | }; 91 | 92 | export const translateByTencent = async ( 93 | content: string 94 | ): Promise<[ResponseData, ResponseError]> => { 95 | const configs = await getLocalItem(); 96 | 97 | return new Promise((resolve, _) => { 98 | fetch("https://transmart.qq.com/api/imt", { 99 | headers: { 100 | "Content-Type": "application/json", 101 | }, 102 | method: "POST", 103 | body: JSON.stringify({ 104 | header: { 105 | fn: "lang_detect", 106 | token: configs.token, 107 | }, 108 | text: content, 109 | }), 110 | }) 111 | .then((response) => response.json()) 112 | .then((data) => { 113 | // D1.获取文本所属语言 114 | const myData = data as LangDetectObject; 115 | console.log("translate_by_tencent1: ", myData); 116 | const { language } = data as LangDetectObject; 117 | const item = languageData.find((item) => { 118 | return item.eng_name.toLowerCase() === language.toLowerCase(); 119 | }); 120 | console.log("code: ", item); 121 | if (!item) { 122 | resolve([null, "该语言无法识别翻译"]); 123 | return; 124 | } 125 | 126 | // D2.通过获取的语言code 在进行翻译 127 | 128 | fetch("https://transmart.qq.com/api/imt", { 129 | headers: { 130 | "Content-Type": "application/json", 131 | }, 132 | method: "POST", 133 | body: JSON.stringify({ 134 | header: { 135 | fn: "auto_translation_block", 136 | token: configs.token, 137 | }, 138 | type: "plain", 139 | source: { 140 | lang: item.code, 141 | text_block: content, 142 | }, 143 | target: { 144 | lang: configs.language, 145 | }, 146 | }), 147 | }) 148 | .then((response) => response.json()) 149 | .then((data) => { 150 | const myData = data as TranslationBlockObject; 151 | console.log("TranslationBlock: ", myData); 152 | resolve([myData.auto_translation, null]); 153 | }) 154 | .catch(() => { 155 | resolve([null, "翻译发生错误"]); 156 | }); 157 | }) 158 | .catch(() => resolve([null, "翻译发生错误"])); 159 | }); 160 | }; 161 | -------------------------------------------------------------------------------- /fast_github/src/types/index.ts: -------------------------------------------------------------------------------- 1 | const FieldType = { 2 | speedNumber: "speedNumber", 3 | speedList: "speedList", 4 | token: "token", 5 | language: "language", 6 | webIDE: "webIDE", 7 | } as const; 8 | 9 | export type FieldTypeKey = keyof typeof FieldType; 10 | 11 | const PageTypeItem = { 12 | releases: "releases", 13 | tags: "tags", 14 | issues: "issues", 15 | undefined: undefined, 16 | tree: "tree", 17 | } as const; 18 | 19 | export type PageTypeKey = keyof typeof PageTypeItem; 20 | export type PageTypeItemValue = typeof PageTypeItem[PageTypeKey]; 21 | 22 | export type ResponseData = string | null; 23 | export type ResponseError = string | null; 24 | 25 | const LanguageItem = { 26 | nothing: "nothing", 27 | zh: "zh", 28 | en: "en", 29 | } as const; 30 | 31 | export type LanguageItemKey = keyof typeof LanguageItem; 32 | // export type LanguageItemValue = typeof LanguageItem[PageTypeKey]; 33 | 34 | const WebIDEItem = { 35 | nothing: "Nothing", 36 | github1s: "GitHub1s.Com", 37 | githubDev: "GitHub.Dev", 38 | } as const; 39 | 40 | export type WebIDEItemKey = keyof typeof WebIDEItem; 41 | export type WebIDEItemValue = typeof WebIDEItem[WebIDEItemKey]; 42 | 43 | export interface DefaultConfig { 44 | importOldList?: boolean; 45 | speedNumber: number; 46 | speedList: string; 47 | token?: string; 48 | language?: LanguageItemKey; 49 | webIDE?: WebIDEItemValue; 50 | } 51 | 52 | export const defaultConfigs: DefaultConfig = { 53 | importOldList: false, 54 | speedNumber: 1, 55 | speedList: "https://gh.api.99988866.xyz/", 56 | token: "", 57 | language: "nothing", 58 | webIDE: "GitHub1s.Com", 59 | }; 60 | 61 | const Status = { 62 | loading: "loading", 63 | complete: "complete", 64 | } as const; 65 | 66 | export type StatusKey = keyof typeof Status; 67 | 68 | export interface MessageType { 69 | status: StatusKey; 70 | url: string; 71 | } 72 | 73 | export interface LanguageType { 74 | code: string; 75 | eng_name: string; 76 | chn_name: string; 77 | } 78 | 79 | export const languageData: Array = [ 80 | { 81 | code: "ar", 82 | eng_name: "arabic", 83 | chn_name: "阿拉伯语", 84 | }, 85 | { 86 | code: "de", 87 | eng_name: "german", 88 | chn_name: "德语", 89 | }, 90 | { 91 | code: "ru", 92 | eng_name: "russian", 93 | chn_name: "俄语", 94 | }, 95 | { 96 | code: "fr", 97 | eng_name: "french", 98 | chn_name: "法语", 99 | }, 100 | { 101 | code: "fil", 102 | eng_name: "filipino", 103 | chn_name: "菲律宾语", 104 | }, 105 | { 106 | code: "km", 107 | eng_name: "khmer", 108 | chn_name: "高棉语", 109 | }, 110 | { 111 | code: "ko", 112 | eng_name: "korean", 113 | chn_name: "韩语", 114 | }, 115 | { 116 | code: "lo", 117 | eng_name: "laos", 118 | chn_name: "老挝语", 119 | }, 120 | { 121 | code: "pt", 122 | eng_name: "portuguese", 123 | chn_name: "葡萄牙语", 124 | }, 125 | { 126 | code: "es", 127 | eng_name: "spanish", 128 | chn_name: "西班牙语", 129 | }, 130 | { 131 | code: "it", 132 | eng_name: "italian", 133 | chn_name: "意大利语", 134 | }, 135 | { 136 | code: "id", 137 | eng_name: "indonesian", 138 | chn_name: "印度尼西亚语", 139 | }, 140 | { 141 | code: "en", 142 | eng_name: "english", 143 | chn_name: "英语", 144 | }, 145 | { 146 | code: "vi", 147 | eng_name: "vietnamese", 148 | chn_name: "越南语", 149 | }, 150 | { 151 | code: "zh", 152 | eng_name: "chinese", 153 | chn_name: "中文", 154 | }, 155 | ]; 156 | 157 | export const onlySupportSelect: Array = [ 158 | { 159 | code: "nothing", 160 | eng_name: "nothing", 161 | chn_name: "不翻译", 162 | }, 163 | { 164 | code: "en", 165 | eng_name: "english", 166 | chn_name: "英语", 167 | }, 168 | { 169 | code: "zh", 170 | eng_name: "chinese", 171 | chn_name: "中文", 172 | }, 173 | ]; 174 | 175 | export interface RuntimeSendMessageType { 176 | content: string; 177 | } 178 | 179 | interface Header { 180 | type: string; 181 | ret_code: string; 182 | time_cost: number; 183 | request_id: string; 184 | } 185 | 186 | export interface LangDetectObject { 187 | header: Header; 188 | language: string; 189 | } 190 | 191 | export interface TranslationBlockObject { 192 | header: Header; 193 | auto_translation: string; 194 | } 195 | -------------------------------------------------------------------------------- /fast_github/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /fast_github/tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./src/options/index.html", 5 | "./src/options/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | } 12 | -------------------------------------------------------------------------------- /fast_github/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ESNext", "DOM"], 7 | "types": ["vite/client","chrome","react"], 8 | "moduleResolution": "Node", 9 | "strict": true, 10 | "resolveJsonModule": true, 11 | "isolatedModules": false, 12 | "esModuleInterop": true, 13 | "noEmit": true, 14 | "jsx": "react-jsx", 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "skipLibCheck": true 19 | }, 20 | "include": ["src"], 21 | "exclude": ["build", "node_modules", "dist"] 22 | } 23 | -------------------------------------------------------------------------------- /fast_github/vite.config.ts: -------------------------------------------------------------------------------- 1 | import react from "@vitejs/plugin-react"; 2 | import path from "path"; 3 | import { defineConfig } from "vite"; 4 | import { default as webExtension } from "vite-plugin-web-extension"; 5 | 6 | function root(...paths: string[]): string { 7 | return path.resolve(__dirname, ...paths); 8 | } 9 | 10 | export default defineConfig({ 11 | root: "src", 12 | build: { 13 | outDir: root("dist"), 14 | emptyOutDir: true, 15 | // sourcemap: true, 16 | minify: "terser", 17 | terserOptions: { 18 | compress: { 19 | drop_console: true, 20 | drop_debugger: true, 21 | }, 22 | }, 23 | }, 24 | plugins: [ 25 | react(), 26 | webExtension({ 27 | disableAutoLaunch: true, 28 | manifest: root("src/manifest.json"), 29 | assets: "assets", 30 | }), 31 | // browserExtension({ 32 | // manifest: root("src/manifest.json"), 33 | // assets: "assets", 34 | // }), 35 | ], 36 | }); 37 | -------------------------------------------------------------------------------- /zip/v1.5.10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.10.zip -------------------------------------------------------------------------------- /zip/v1.5.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.2.zip -------------------------------------------------------------------------------- /zip/v1.5.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.3.zip -------------------------------------------------------------------------------- /zip/v1.5.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.4.zip -------------------------------------------------------------------------------- /zip/v1.5.5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.5.zip -------------------------------------------------------------------------------- /zip/v1.5.6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.6.zip -------------------------------------------------------------------------------- /zip/v1.5.7.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.7.zip -------------------------------------------------------------------------------- /zip/v1.5.8.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.8.zip -------------------------------------------------------------------------------- /zip/v1.5.9.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fhefh2015/Fast-GitHub/7cdec98e4d9f4202c6ab0329c3a83dd5a1899fc3/zip/v1.5.9.zip --------------------------------------------------------------------------------