Browse Source

perf: 增加gg proxy

pull/180/head
xiaojunnuo 4 years ago
parent
commit
fe57640317
  1. 8
      packages/core/src/config/index.js
  2. 20
      packages/gui/extra/scripts/google.js
  3. 7
      packages/gui/src/view/style/index.scss
  4. 1
      packages/mitmproxy/src/lib/monkey/index.js
  5. 1
      packages/mitmproxy/src/lib/proxy/middleware/InsertScriptMiddleware.js

8
packages/core/src/config/index.js

@ -98,7 +98,13 @@ module.exports = {
'.*': { proxy: 'google-themes.proxy.ustclug.org' } '.*': { proxy: 'google-themes.proxy.ustclug.org' }
}, },
'www.google.com': { 'www.google.com': {
'/recaptcha/.*': { proxy: 'www.recaptcha.net' } '/recaptcha/.*': { proxy: 'www.recaptcha.net' },
'.*': {
proxy: 'gg.docmirror.top/_yxorp',
script: [
'google'
]
}
}, },
'fonts.gstatic.com': { 'fonts.gstatic.com': {
'.*': { '.*': {

20
packages/gui/extra/scripts/google.js

@ -0,0 +1,20 @@
// ==UserScript==
// @name google增强
// @version 1.2.4
// @author Greper
// @description 去除ping链接
// @match https://www.google.com/*/*
// @icon https://www.google.com/favicon.ico
// @license GPL-3.0 License
// @run-at document-end
// @namespace
// ==/UserScript==
(function () {
console.log('google script loaded')
const aList = document.getElementsByTagName('a')
for (let i = 0; i <= aList.length; i++) {
console.log(aList[i].href)
aList[i].ping = undefined
}
})()

7
packages/gui/src/view/style/index.scss

@ -36,3 +36,10 @@
.md-mb-10{margin-bottom: 10px;} .md-mb-10{margin-bottom: 10px;}
.md-mb-15{margin-bottom: 15px;} .md-mb-15{margin-bottom: 15px;}
.md-mb-20{margin-bottom: 20px;} .md-mb-20{margin-bottom: 20px;}
ol{
margin-block-start: 0em;
margin-block-end: 0em;
padding-inline-start: 20px;
}

1
packages/mitmproxy/src/lib/monkey/index.js

@ -71,6 +71,7 @@ const api = {
load (rootDir) { load (rootDir) {
scripts = {} scripts = {}
scripts.github = loadScript(readFile(rootDir, 'github.script')) scripts.github = loadScript(readFile(rootDir, 'github.script'))
scripts.google = loadScript(readFile(rootDir, 'google.js'))
scripts.jquery = { script: readFile(rootDir, 'jquery.min.js') } scripts.jquery = { script: readFile(rootDir, 'jquery.min.js') }
scripts.global = { script: readFile(rootDir, 'global.script') } scripts.global = { script: readFile(rootDir, 'global.script') }
return scripts return scripts

1
packages/mitmproxy/src/lib/proxy/middleware/InsertScriptMiddleware.js

@ -48,6 +48,7 @@ function injectScriptIntoHtml (tags, chunk, script) {
if (index < 0) { if (index < 0) {
continue continue
} }
console.log('insert script:', tag)
const scriptBuf = Buffer.from(script) const scriptBuf = Buffer.from(script)
const chunkNew = Buffer.alloc(chunk.length + scriptBuf.length) const chunkNew = Buffer.alloc(chunk.length + scriptBuf.length)
chunk.copy(chunkNew, 0, 0, index) chunk.copy(chunkNew, 0, 0, index)

Loading…
Cancel
Save