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