mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2025-03-03 19:55:48 +03:00
Restyle, start transferring to async storage, manifest now generates mv3 and mv2 (not tested)
This commit is contained in:
parent
df8d1dfe0c
commit
991022b83c
|
@ -0,0 +1,5 @@
|
|||
console.log('Shimming for mv3...');
|
||||
|
||||
if (!chrome.browserAction) {
|
||||
chrome.browserAction = chrome.action;
|
||||
}
|
|
@ -137,20 +137,21 @@ console.log('Extension started.');
|
|||
|
||||
createStorage(prefix) {
|
||||
|
||||
return function state(key, value) {
|
||||
return async function state(key, value) {
|
||||
|
||||
const storage = chrome.storage.local;
|
||||
key = prefix + key;
|
||||
if (value === null) {
|
||||
return globalThis.localStorage.removeItem(key);
|
||||
return storage.remove(key);
|
||||
}
|
||||
if (value === undefined) {
|
||||
const item = globalThis.localStorage.getItem(key);
|
||||
const item = await storage.get(key);
|
||||
return item && JSON.parse(item);
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
throw new TypeError('Converting Date format to JSON is not supported.');
|
||||
}
|
||||
globalThis.localStorage.setItem(key, JSON.stringify(value));
|
||||
storage.set({[key]: JSON.stringify(value)});
|
||||
|
||||
};
|
||||
|
||||
|
@ -240,11 +241,11 @@ console.log('Extension started.');
|
|||
|
||||
let parts;
|
||||
parts = crededAddr.split('@');
|
||||
let [creds, addr] = [parts.slice(0, -1).join('@'), parts[parts.length - 1]];
|
||||
const [creds, addr] = [parts.slice(0, -1).join('@'), parts[parts.length - 1]];
|
||||
|
||||
const [hostname, port] = addr.split(':');
|
||||
|
||||
parts = creds.split(':')
|
||||
parts = creds.split(':');
|
||||
const username = parts[0];
|
||||
const password = parts.slice(1).join(':');
|
||||
|
||||
|
@ -255,7 +256,7 @@ console.log('Extension started.');
|
|||
hostname,
|
||||
port,
|
||||
creds,
|
||||
}
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
|
@ -263,7 +264,7 @@ console.log('Extension started.');
|
|||
|
||||
chrome.tabs.create(
|
||||
{url: url},
|
||||
(tab) => chrome.globalThiss.update(tab.globalThisId, {focused: true})
|
||||
(tab) => chrome.globalThiss.update(tab.globalThisId, {focused: true}),
|
||||
);
|
||||
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import './00---mv3-shim.mjs';
|
||||
import './00-init-apis.mjs';
|
||||
${scripts_0x}
|
||||
import './11-error-handlers-api.mjs';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"manifest_version": ${manifestVersion},
|
||||
|
||||
"name": "__MSG_extName__",
|
||||
"default_locale": "ru",
|
||||
|
@ -21,6 +21,9 @@
|
|||
, "notifications"
|
||||
${extraPermissions}
|
||||
],
|
||||
|
||||
${hostPermissions}
|
||||
|
||||
"minimum_chrome_version": "55.0.0.0",
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
|
@ -36,18 +39,14 @@
|
|||
}
|
||||
},
|
||||
|
||||
"background": {
|
||||
${persistent}
|
||||
"page": "./bg.html"
|
||||
},
|
||||
${background},
|
||||
|
||||
"browser_action": {
|
||||
"${action}": {
|
||||
"default_title": "Этот сайт благословлён | Версия ${version + versionSuffix}",
|
||||
"default_popup": "/pages/options/index.html"
|
||||
},
|
||||
"options_ui": {
|
||||
"page": "/pages/options/index.html",
|
||||
"chrome_style": false
|
||||
"page": "/pages/options/index.html"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
{
|
||||
const chromified = globalThis.utils.chromified;
|
||||
|
||||
const lastErrors = [];
|
||||
const lastErrorsLength = 20;
|
||||
|
||||
const IF_COLL_KEY = 'err-to-exc-if-coll';
|
||||
const state = await globalThis.utils.createstate('err-to-exc');
|
||||
const IF_COLL_KEY = 'if-coll';
|
||||
|
||||
|
||||
const privates = {
|
||||
ifCollecting: globalThis.localStorage[IF_COLL_KEY] || false,
|
||||
ifCollecting: (await state.get(IF_COLL_KEY)) || false,
|
||||
};
|
||||
|
||||
const that = globalThis.apis.lastNetErrors = {
|
||||
|
@ -21,11 +21,12 @@
|
|||
|
||||
set ifCollecting(newValue) {
|
||||
|
||||
privates.ifCollecting = globalThis.localStorage[IF_COLL_KEY] = newValue;
|
||||
privates.ifCollecting = newValue;
|
||||
state.set(IF_COLL_KEY, newValue);
|
||||
|
||||
},
|
||||
get: () => lastErrors,
|
||||
}
|
||||
};
|
||||
|
||||
chrome.webRequest.onErrorOccurred.addListener(chromified((err/*Ignored*/, details) => {
|
||||
|
||||
|
@ -48,8 +49,5 @@
|
|||
lastErrors.pop();
|
||||
}
|
||||
|
||||
}),
|
||||
{urls: ['<all_urls>']}
|
||||
}), {urls: ['<all_urls>']},
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,21 @@ const contexts = {};
|
|||
const extraPermissions = ', "webRequest", "webRequestBlocking", "webNavigation"';
|
||||
|
||||
contexts.full = Object.assign({}, commonContext, {
|
||||
manifestVersion: '3',
|
||||
versionSuffix: '',
|
||||
nameSuffixEn: '',
|
||||
nameSuffixRu: '',
|
||||
hostPermissions: `"host_permissions": [
|
||||
"*://*/*"
|
||||
],`,
|
||||
extraPermissions,
|
||||
persistent: '',
|
||||
action: 'action',
|
||||
background: `
|
||||
"background": {
|
||||
"service_worker": "./index.mjs",
|
||||
"type": "module"
|
||||
}
|
||||
`,
|
||||
scripts_0x: '',
|
||||
scripts_2x: "import './20-ip-to-host-api.mjs';",
|
||||
scripts_8x: `
|
||||
|
@ -34,11 +44,19 @@ contexts.full = Object.assign({}, commonContext, {
|
|||
});
|
||||
|
||||
contexts.mini = Object.assign({}, commonContext, {
|
||||
manifestVersion: '2',
|
||||
versionSuffix: '-mini',
|
||||
nameSuffixEn: ' MINI',
|
||||
nameSuffixRu: ' МИНИ',
|
||||
extraPermissions: '',
|
||||
persistent: '"persistent": false,',
|
||||
hostPermissions: '',
|
||||
action: 'browser_action',
|
||||
background: `
|
||||
"background": {
|
||||
"persistent": false,
|
||||
"page": "./bg.html"
|
||||
}
|
||||
`,
|
||||
scripts_0x: '',
|
||||
scripts_2x: "import '20-for-mini-only.mjs';",
|
||||
scripts_8x: '',
|
||||
|
|
Loading…
Reference in New Issue
Block a user