forked from jianjianai/ms-copilot-play
-
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
1 parent
730b616
commit 7ceb26e
Showing
3 changed files
with
82 additions
and
40 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,71 @@ | ||
<script> | ||
//验证通过器 | ||
(() => { | ||
//解析器 | ||
function pathOrUrl(value) { | ||
if (!value) { | ||
return undefined; | ||
} | ||
if ((typeof value) != "string") { | ||
value = `${value};` | ||
} | ||
try { | ||
return new URL(value); | ||
} catch (e) { | ||
if (value.startsWith("/")) { | ||
let url = new URL(`${window.location.origin}${value}`) | ||
return url | ||
} else { | ||
return new URL(`${window.location.href.substring(0, window.location.href.lastIndexOf("/"))}/${value}`); | ||
} | ||
} | ||
} | ||
//feth请求编辑 | ||
const myFetch = window.fetch; | ||
window.fetch = (input, init) => { | ||
let url = pathOrUrl(input); | ||
if (url) { | ||
url.pathname = url.pathname.replace("/cdn-cgi/", "/pocybig/"); | ||
console.log("已拦重定向请求=>", input, url.toString()); | ||
return myFetch(url, init); | ||
} | ||
return myFetch(input, init); | ||
} | ||
//xml请求编辑 | ||
const myXMLHttpRequestOpen = window.XMLHttpRequest.prototype.open; | ||
XMLHttpRequest.prototype.open = function () { | ||
if ((typeof arguments[1]) == "string") { | ||
arguments[1] = arguments[1].replace("/cdn-cgi/", "/pocybig/"); | ||
} | ||
return myXMLHttpRequestOpen.apply(this, arguments); | ||
} | ||
|
||
document.myCreateElement = document.createElement; | ||
document.createElement = function () { | ||
const el = document.myCreateElement(...arguments); | ||
if (arguments[0] == "img") { | ||
// el = new Proxy(el,{ | ||
// set(target, property, value){ | ||
// console.log("setImg",property,value); | ||
// target[property] = value; | ||
// } | ||
// }) | ||
Object.defineProperty(el, "src", { | ||
set(value) { | ||
console.log("set img src",value); | ||
value = value.replace("/cdn-cgi/","/pocybig/"); | ||
el.setAttribute("src",value); | ||
console.log(el); | ||
}, | ||
get() { | ||
return el.getAttribute("src"); | ||
} | ||
}) | ||
console.log("createElement", el, arguments); | ||
} | ||
return el; | ||
} | ||
|
||
})(); | ||
console.log("注入成功!"); | ||
</script> |
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
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