Skip to content

Commit

Permalink
音乐生成
Browse files Browse the repository at this point in the history
  • Loading branch information
jianjianai authored Jun 12, 2024
2 parents 92b40d9 + 754e9d7 commit 28e7b20
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 39 deletions.
File renamed without changes.
File renamed without changes.
136 changes: 136 additions & 0 deletions src/html/CopilotInjection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<script>
//copilot主页面
(() => {
//解析器
function pathOrUrl(value) {
if (!value) {
return value;
}
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}`);
}
}
}

//是否放行
function isItReleased(url) {
if (!url) {
return true;
}
if (
url.pathname == "/fd/ls/ls.gif" ||
url.pathname == "/fd/ls/l" ||
url.pathname == "/fd/ls/lsp.aspx"
) {
return false;
}
return true;
}

// url编辑
function urlEdit(url) {
if(!url){
return url;
}
if (
url.hostname == "www.bing.com" ||
url.hostname == "copilot.microsoft.com" ||
url.hostname == "bat.bing.com" ||
url.hostname == "sydney.bing.com"
) {
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;
console.log("edit =>", url);
}
return url;
}

//feth请求编辑
const myFetch = window.fetch;
window.fetch = async (input, init) => {
let url = pathOrUrl(input);
if(!isItReleased(url)){
console.log("已拦截无用请求=>", input,init);
throw new Error("404!!!");
}
url = urlEdit(url);
return myFetch(url, init);
}

//xml请求编辑
const myXMLHttpRequestOpen = window.XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
let url = pathOrUrl(arguments[1]);
if(!isItReleased(url)){
this.intercepted_mscp = true;
console.log("已拦截无用请求=>", arguments);
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 = (qurl, data) => {
let url = pathOrUrl(qurl);
if(!isItReleased(url)){
console.log("已拦截无用统计请求=>", qurl, data);
return;
}
return mySendBeacon.call(window.navigator,qurl,data);
}

//img请求
const myImage = window.Image;
window.Image = new Proxy(myImage, {
construct(target, argumentsList) {
const img = new myImage(...argumentsList);
const imgSrcSet = img.__proto__.__lookupSetter__('src');
img.__proto__.__defineSetter__('src', function (value) {
const url = pathOrUrl(value);
if(!isItReleased(url)){
console.log("已拦截无用请求=>", value);
return;
}
imgSrcSet.call(this, value);
console.log(img);
});
return img;
}
});

})();
</script>
68 changes: 33 additions & 35 deletions src/CopilotInjection.html → src/html/ImagesCreateInJection.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script>
// 音乐生成子页面
(() => {
//解析器
function pathOrUrl(value) {
if (!value) {
return null;
return value;
}
if (value instanceof URL) {
return value;
Expand All @@ -23,51 +24,45 @@
}
}

//重定向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;
//是否放行
function isItReleased(url) {
if (!url) {
return true;
}
if (
url.pathname == "/fd/ls/ls.gif" ||
url.pathname == "/fd/ls/l" ||
url.pathname == "/fd/ls/lsp.aspx"
) {
return false;
}
return true;
}

// 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) => {
window.fetch = async (input, init) => {
let url = pathOrUrl(input);
if (!url) {
return myFetch(input, init);
if(!isItReleased(url)){
console.log("已拦截无用请求=>", input,init);
throw new Error("404!!!");
}
return myFetch(urlEdit(url), init);
url = urlEdit(url);
return myFetch(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);
if(!isItReleased(url)){
this.intercepted_mscp = true;
console.log("已拦截无用请求=>", arguments);
return;
}
arguments[1] = urlEdit(url);
Expand All @@ -92,8 +87,13 @@

//sendBeacon请求
const mySendBeacon = window.navigator.sendBeacon;
window.navigator.sendBeacon = (url, data) => {
console.log("已拦截无用统计请求=>", url, data);
window.navigator.sendBeacon = (qurl, data) => {
let url = pathOrUrl(qurl);
if(!isItReleased(url)){
console.log("已拦截无用统计请求=>", qurl, data);
return;
}
return mySendBeacon.call(window.navigator,qurl,data);
}

//img请求
Expand All @@ -104,11 +104,9 @@
const imgSrcSet = img.__proto__.__lookupSetter__('src');
img.__proto__.__defineSetter__('src', function (value) {
const url = pathOrUrl(value);
if (url) {
if (url.pathname == "/fd/ls/l") {
console.log("已拦截无用请求=>", value);
return;
}
if(!isItReleased(url)){
console.log("已拦截无用请求=>", value);
return;
}
imgSrcSet.call(this, value);
console.log(img);
Expand Down
119 changes: 119 additions & 0 deletions src/html/MusicInJection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<script>
// 音乐生成子页面
(() => {
//解析器
function pathOrUrl(value) {
if (!value) {
return value;
}
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}`);
}
}
}

//是否放行
function isItReleased(url) {
if (!url) {
return true;
}
if (
url.pathname == "/fd/ls/ls.gif" ||
url.pathname == "/fd/ls/l" ||
url.pathname == "/fd/ls/lsp.aspx"
) {
return false;
}
return true;
}

// url编辑
function urlEdit(url) {
return url;
}

//feth请求编辑
const myFetch = window.fetch;
window.fetch = async (input, init) => {
let url = pathOrUrl(input);
if(!isItReleased(url)){
console.log("已拦截无用请求=>", input,init);
throw new Error("404!!!");
}
url = urlEdit(url);
return myFetch(url, init);
}

//xml请求编辑
const myXMLHttpRequestOpen = window.XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
let url = pathOrUrl(arguments[1]);
if(!isItReleased(url)){
this.intercepted_mscp = true;
console.log("已拦截无用请求=>", arguments);
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 = (qurl, data) => {
let url = pathOrUrl(qurl);
if(!isItReleased(url)){
console.log("已拦截无用统计请求=>", qurl, data);
return;
}
return mySendBeacon.call(window.navigator,qurl,data);
}

//img请求
const myImage = window.Image;
window.Image = new Proxy(myImage, {
construct(target, argumentsList) {
const img = new myImage(...argumentsList);
const imgSrcSet = img.__proto__.__lookupSetter__('src');
img.__proto__.__defineSetter__('src', function (value) {
const url = pathOrUrl(value);
if(!isItReleased(url)){
console.log("已拦截无用请求=>", value);
return;
}
imgSrcSet.call(this, value);
console.log(img);
});
return img;
}
});

})();
</script>
Loading

0 comments on commit 28e7b20

Please sign in to comment.