Skip to content

Commit

Permalink
chore(deps): upgrade kkt to ~7.1.5 & Migrating to Manifest V3
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 26, 2022
1 parent 4e950ee commit 6a90313
Show file tree
Hide file tree
Showing 11 changed files with 29,380 additions and 10,968 deletions.
71 changes: 35 additions & 36 deletions chrome-main/background.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@

chrome.browserAction.onClicked.addListener(function () {
chrome.management.getSelf(function (res) {
// moz-extension://9dc71e1a-5801-b14e-906e-883d3c24d07e/7e4e10b3bb36ac2d03095a183833b2b1.html#/
chrome.tabs.create({ url: 'chrome-extension://' + res.id + '/index.html#normal' });
});
// chrome.tabs.create({ url: 'chrome://newtab' });
});
// chrome.action.onClicked.addListener(tab => {
// chrome.management.getSelf(function (res) {
// // moz-extension://9dc71e1a-5801-b14e-906e-883d3c24d07e/7e4e10b3bb36ac2d03095a183833b2b1.html#/
// chrome.tabs.create({ url: 'chrome-extension://' + res.id + '/index.html#normal' });
// });
// });


chrome.webRequest.onHeadersReceived.addListener(details => {
const responseHeaders = details.responseHeaders.map(header => {
const isCSPHeader = /content-security-policy/i.test(header.name);
const isFrameHeader = /x-frame-options/i.test(header.name);
if (isCSPHeader) {
let csp = header.value
// csp = csp.replace('script-src', `script-src ${hosts}`)
// csp = csp.replace('style-src', `style-src ${hosts}`)
// csp = csp.replace('frame-src', `frame-src ${iframeHosts}`)
// csp = csp.replace('child-src', `child-src ${hosts}`)
csp = csp.replace(/frame-ancestors (.*?);/ig, "");
// header.value = csp;
header.value = csp + 'sandbox;';
} else if (isFrameHeader) {
header.value = 'ALLOWALL';
}
return header
});
return { responseHeaders };
},
{
urls: ['<all_urls>', '*://*/*'],
types: ['sub_frame']
},
[
'blocking',
'responseHeaders'
]
)
// chrome.webRequest.onHeadersReceived.addListener(details => {
// const responseHeaders = details.responseHeaders.map(header => {
// const isCSPHeader = /content-security-policy/i.test(header.name);
// const isFrameHeader = /x-frame-options/i.test(header.name);
// if (isCSPHeader) {
// let csp = header.value
// // csp = csp.replace('script-src', `script-src ${hosts}`)
// // csp = csp.replace('style-src', `style-src ${hosts}`)
// // csp = csp.replace('frame-src', `frame-src ${iframeHosts}`)
// // csp = csp.replace('child-src', `child-src ${hosts}`)
// csp = csp.replace(/frame-ancestors (.*?);/ig, "");
// // header.value = csp;
// header.value = csp + 'sandbox;';
// } else if (isFrameHeader) {
// header.value = 'ALLOWALL';
// }
// return header
// });
// return { responseHeaders };
// },
// {
// urls: ['<all_urls>', '*://*/*'],
// types: ['sub_frame']
// },
// [
// 'blocking',
// 'responseHeaders'
// ]
// )
16 changes: 4 additions & 12 deletions chrome-main/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@
"128": "osc-logo.png"
},
"permissions": [
"*://*.git.luolix.top/*",
"*://www.oschina.net/*",
"tabs",
"activeTab",
"unlimitedStorage",
"storage",
"history",
"chrome://favicon/",
"management",
"webRequest",
"webRequestBlocking"
"scripting"
],
"host_permissions": ["https://www.oschina.net/", "https://github.com/"],
"manifest_version": 3,
"background": {
"scripts": [
"background.js"
]
},
"browser_action": {
"default_title": "",
"default_icon": "osc-logo.png"
"service_worker": "background.js"
},
"offline_enabled": true,
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"
}
Expand Down
Loading

0 comments on commit 6a90313

Please sign in to comment.