mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-10 19:46:34 +03:00
Fix several errors caused by migration to mv3 (storage, blocking requests, top level await, <all_urls>)
This commit is contained in:
parent
5a66e5b350
commit
0116f18c70
|
@ -146,7 +146,8 @@ console.log('Extension started.');
|
|||
}
|
||||
if (value === undefined) {
|
||||
const item = await storage.get(key);
|
||||
return item && JSON.parse(item);
|
||||
console.log('ITEM:', item);
|
||||
return item;
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
throw new TypeError('Converting Date format to JSON is not supported.');
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
},
|
||||
{urls: ['<all_urls>']},
|
||||
['blocking'],
|
||||
);
|
||||
|
||||
const forgetRequestId = (details) => {
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
if (err) {
|
||||
if (err.message === 'proxy.settings requires private browsing permission.') {
|
||||
clarifyThen(
|
||||
chrome.i18n.getMessage('AllowExtensionToRunInPrivateWindows'),
|
||||
chrome.i18n.getMessage('AllowExtensionToRunInPrivateglobalThiss'),
|
||||
cb,
|
||||
)(err);
|
||||
return;
|
||||
|
@ -677,8 +677,8 @@
|
|||
|
||||
console.log('Updating from', oldAntiCensorRu.version, 'to', antiCensorRu.version);
|
||||
try {
|
||||
if (window.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.59')) {
|
||||
window.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls = [
|
||||
if (globalThis.apis.version.isLeq(oldAntiCensorRu.version, '0.0.1.59')) {
|
||||
globalThis.apis.antiCensorRu.pacProviders['Антизапрет'].pacUrls = [
|
||||
'https://antizapret.prostovpn.org:8443/proxy.pac',
|
||||
'https://antizapret.prostovpn.org:18443/proxy.pac',
|
||||
'https://antizapret.prostovpn.org/proxy.pac',
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
chrome.commands.onCommand.addListener((command) => {
|
||||
if (command === 'toggle-pac-script') {
|
||||
console.log("Toggling PAC-script!");
|
||||
}
|
||||
});
|
||||
/* Not used.
|
||||
{
|
||||
chrome.commands.onCommand.addListener((command) => {
|
||||
if (command === 'toggle-pac-script') {
|
||||
console.log('Toggling PAC-script!');
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
, "alarms"
|
||||
, "storage"
|
||||
, "unlimitedStorage"
|
||||
, "<all_urls>"
|
||||
, "tabs"
|
||||
, "contextMenus"
|
||||
, "notifications"
|
||||
|
|
|
@ -1,53 +1,55 @@
|
|||
|
||||
const chromified = globalThis.utils.chromified;
|
||||
(async () => {
|
||||
const chromified = globalThis.utils.chromified;
|
||||
|
||||
const lastErrors = [];
|
||||
const lastErrorsLength = 20;
|
||||
const lastErrors = [];
|
||||
const lastErrorsLength = 20;
|
||||
|
||||
const state = await globalThis.utils.createstate('err-to-exc');
|
||||
const IF_COLL_KEY = 'if-coll';
|
||||
const state = await globalThis.utils.createStorage('err-to-exc');
|
||||
const IF_COLL_KEY = 'if-coll';
|
||||
|
||||
|
||||
const privates = {
|
||||
ifCollecting: (await state.get(IF_COLL_KEY)) || false,
|
||||
};
|
||||
const privates = {
|
||||
ifCollecting: (await state(IF_COLL_KEY)) || false,
|
||||
};
|
||||
|
||||
const that = globalThis.apis.lastNetErrors = {
|
||||
get ifCollecting() {
|
||||
const that = globalThis.apis.lastNetErrors = {
|
||||
get ifCollecting() {
|
||||
|
||||
return privates.ifCollecting;
|
||||
return privates.ifCollecting;
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
set ifCollecting(newValue) {
|
||||
set ifCollecting(newValue) {
|
||||
|
||||
privates.ifCollecting = newValue;
|
||||
state.set(IF_COLL_KEY, newValue);
|
||||
privates.ifCollecting = newValue;
|
||||
state(IF_COLL_KEY, newValue);
|
||||
|
||||
},
|
||||
get: () => lastErrors,
|
||||
};
|
||||
},
|
||||
get: () => lastErrors,
|
||||
};
|
||||
|
||||
chrome.webRequest.onErrorOccurred.addListener(chromified((err/* Ignored */, details) => {
|
||||
chrome.webRequest.onErrorOccurred.addListener(chromified((err/* Ignored */, details) => {
|
||||
|
||||
if (!that.ifCollecting || [
|
||||
'net::ERR_BLOCKED_BY_CLIENT',
|
||||
'net::ERR_ABORTED',
|
||||
'net::ERR_CACHE_MISS',
|
||||
'net::ERR_INSUFFICIENT_RESOURCES',
|
||||
].includes(details.error) ) {
|
||||
return;
|
||||
}
|
||||
const last = lastErrors[0];
|
||||
if (last && details.error === last.error && details.url === last.url) {
|
||||
// Dup.
|
||||
return;
|
||||
}
|
||||
if (!that.ifCollecting || [
|
||||
'net::ERR_BLOCKED_BY_CLIENT',
|
||||
'net::ERR_ABORTED',
|
||||
'net::ERR_CACHE_MISS',
|
||||
'net::ERR_INSUFFICIENT_RESOURCES',
|
||||
].includes(details.error) ) {
|
||||
return;
|
||||
}
|
||||
const last = lastErrors[0];
|
||||
if (last && details.error === last.error && details.url === last.url) {
|
||||
// Dup.
|
||||
return;
|
||||
}
|
||||
|
||||
lastErrors.unshift(details);
|
||||
if (lastErrors.length > lastErrorsLength) {
|
||||
lastErrors.pop();
|
||||
}
|
||||
lastErrors.unshift(details);
|
||||
if (lastErrors.length > lastErrorsLength) {
|
||||
lastErrors.pop();
|
||||
}
|
||||
|
||||
}), {urls: ['<all_urls>']},
|
||||
);
|
||||
}), {urls: ['<all_urls>']},
|
||||
);
|
||||
})();
|
||||
|
|
|
@ -16,7 +16,7 @@ const commonContext = {
|
|||
|
||||
const contexts = {};
|
||||
|
||||
const extraPermissions = ', "webRequest", "webRequestBlocking", "webNavigation"';
|
||||
const extraPermissions = ', "webRequest", "webNavigation"';
|
||||
|
||||
contexts.full = Object.assign({}, commonContext, {
|
||||
manifestVersion: '3',
|
||||
|
|
Loading…
Reference in New Issue
Block a user