Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
jianjianai committed Jun 9, 2024
1 parent 75e59d0 commit ff1b0f0
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 89 deletions.
119 changes: 119 additions & 0 deletions src/CopilotInjection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<script>
(() => {
//解析器
function pathOrUrl(value) {
if (!value) {
return null;
}
if (value instanceof URL) {
return value;
}
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}`);
}
}
}

//重定向url到自己
function redirectToLoc(url) {
url.searchParams.set("cprt",url.hostname);
url.searchParams.set("cprtp",url.port);
url.searchParams.set("cprtl",url.protocol);
url.hostname = window.location.hostname;
url.port = window.location.port;
url.protocol = window.location.protocol;
return url;
}

// url编辑
function urlEdit(url) {
if (
url.hostname == "www.bing.com" ||
url.hostname == "copilot.microsoft.com" ||
url.hostname == "bat.bing.com" ||
url.hostname == "sydney.bing.com"
) {
url = redirectToLoc(url);
console.log("edit =>",url);
}
return url;
}

//feth请求编辑
const myFetch = window.fetch;
window.fetch = (input, init) => {
let url = pathOrUrl(input);
if (!url) {
return myFetch(input, init);
}
return myFetch(urlEdit(url), init);
}

//xml请求编辑
const myXMLHttpRequestOpen = window.XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
let url = pathOrUrl(arguments[1]);
if (!url) {
return myXMLHttpRequestOpen.apply(this, arguments);
}
if (url.pathname == "/fd/ls/lsp.aspx") {
console.log("已拦截无用请求=>", arguments);
this.intercepted_mscp = true;
return;
}
arguments[1] = urlEdit(url);
return myXMLHttpRequestOpen.apply(this, arguments);
}
const myXMLHttpRequestSend = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function () {
if (this.intercepted_mscp) {
console.log("已拦截无用请求=>>>>>>>>>>>", this);
return;
}
return myXMLHttpRequestSend.apply(this, arguments);
}
const myXMLSetRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader
window.XMLHttpRequest.prototype.setRequestHeader = function(){
if (this.intercepted_mscp) {
console.log("已拦截无用请求=>>>>>>>>>>>", this);
return;
}
return myXMLSetRequestHeader.apply(this, arguments);
}

//sendBeacon请求
const mySendBeacon = window.navigator.sendBeacon;
window.navigator.sendBeacon = (url, data) => {
console.log("已拦截无用统计请求=>", url, data);
}

//img请求
const myImage = window.Image;
window.Image = new Proxy(myImage, {
construct(target, argumentsList) {
return new Proxy(new myImage(...argumentsList), {
set(target, property, value) {
const url = pathOrUrl(value);
if (url) {
if (url.pathname == "/fd/ls/l") {
console.log("已拦截无用请求=>", value);
return;
}
}
console.log(url, value);
target[property] = value;
}
});
}
})
})();
</script>
80 changes: 0 additions & 80 deletions src/CopilotNetWork.html

This file was deleted.

36 changes: 27 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { proxyLinkHttp } from "./proxyLink/proxyLinkHttp";
import { usIps } from './ips/usIps';
import CopilotNetWork from './CopilotNetWork.html';
import CopilotInjection from './CopilotInjection.html';
import CFTuring from './CFTuring.html';
import CFTNormalUring from './CFTNormalUring.html';

Expand Down Expand Up @@ -124,7 +124,7 @@ export default {
originUrl.hostname = "www.bing.com"
// originUrl.pathname = originUrl.pathname.replace("/pocybig/","/cdn-cgi/");
}
resHeaders.set('Origin',originUrl.toString());
resHeaders.set('Origin',originUrl.origin);
}
return config;
},
Expand Down Expand Up @@ -164,7 +164,7 @@ export default {
const url = config.url as URL;
const p = url.pathname;
if(p=="/secure/Passport.aspx" || p=="/passport.aspx"){
url.searchParams.set("requrl","https://copilot.microsoft.com/?wlsso=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1");
url.searchParams.set("requrl","https://copilot.microsoft.com/?wlsso=1&wlexpsignin=1");
}
return config;
},
Expand All @@ -173,7 +173,7 @@ export default {
const url = config.url as URL;
const p = url.pathname;
if(p=="/fd/auth/signin"){
url.searchParams.set("return_url","https://copilot.microsoft.com/?wlsso=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1&wlexpsignin=1");
url.searchParams.set("return_url","https://copilot.microsoft.com/?wlsso=1&wlexpsignin=1");
}
return config;
},
Expand Down Expand Up @@ -201,7 +201,27 @@ export default {
url.searchParams.set("DATA",sdata);
}
return config;
},
//不同域重定向转换
async (config)=>{
const url = config.url as URL;
if(url.searchParams.has("cprt")){
url.hostname = url.searchParams.get("cprt");
url.searchParams.delete("cprt");
return config;
}
if(url.searchParams.has("cprtp")){
url.port = url.searchParams.get("cprtp");
url.searchParams.delete("cprtp");

}
if(url.searchParams.has("cprtl")){
url.protocol = url.searchParams.get("cprtl");
url.searchParams.delete("cprtl");
}
return config;
}

],[
//基本转换
async (config)=>{
Expand Down Expand Up @@ -229,7 +249,7 @@ export default {
async (config,res)=>{
const resHeaders = config.init.headers as Headers;
const contentType = res.headers.get("Content-Type");
if (!contentType || (!contentType.startsWith("text/") && !contentType.startsWith("application/javascript"))) {
if (!contentType || (!contentType.startsWith("text/") && !contentType.startsWith("application/javascript") && !contentType.startsWith("application/json"))) {
return config;
}
resHeaders.delete("Content-Md5");
Expand All @@ -239,14 +259,12 @@ export default {
retBody = retBody.replace(/https?:\/\/copilot\.microsoft\.com(:[0-9]{1,6})?/g, `${porxyOrigin}`);
retBody = retBody.replace(/https?:\/\/www\.bing\.com(:[0-9]{1,6})?/g,`${porxyOrigin}`);
retBody = retBody.replace(/https?:\/\/storage\.live\.com(:[0-9]{1,6})?/g, `${porxyOrigin}`);
// retBody = retBody.replace(/https?:\\\/\\\/copilot\.microsoft\.com(:[0-9]{1,6})?/g, `${porxyOrigin.replaceAll("/",`\\/`)}`);
// retBody = retBody.replaceAll(`"copilot.microsoft.com"`,`"${porxyHostName}"`);
// retBody = retBody.replaceAll(`"copilot.microsoft.com/"`,`"${porxyHostName}/"`);

const resUrl = new URL(res.url);

//特定页面注入脚本
if(resUrl.pathname=="/"){
retBody = injectionHtml(retBody,CopilotNetWork);
retBody = injectionHtml(retBody,CopilotInjection);
}
//验证页面转换
if(resUrl.pathname=="/turing/captcha/challenge"){
Expand Down

0 comments on commit ff1b0f0

Please sign in to comment.