Chrome stuff removed (#1274)
This commit is contained in:
parent
b30a0b922d
commit
6fabde4c11
|
@ -194,69 +194,69 @@ const Allowlist = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const BrowserType = {
|
const BrowserType = {
|
||||||
'CHROMIUM': chrome.runtime.getURL('/').startsWith('chrome-extension'),
|
'CHROMIUM': browser.runtime.getURL('/').startsWith('chrome-extension'),
|
||||||
'FIREFOX': chrome.runtime.getURL('/').startsWith('moz-extension')
|
'FIREFOX': browser.runtime.getURL('/').startsWith('moz-extension')
|
||||||
};
|
};
|
||||||
|
|
||||||
const IconType = {
|
const IconType = {
|
||||||
'Default': {
|
'Default': {
|
||||||
'Enabled': {
|
'Enabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/default/icon16-default.png'),
|
'16': browser.runtime.getURL('icons/action/default/icon16-default.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/default/icon18-default.png'),
|
'18': browser.runtime.getURL('icons/action/default/icon18-default.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/default/icon19-default.png'),
|
'19': browser.runtime.getURL('icons/action/default/icon19-default.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/default/icon32-default.png'),
|
'32': browser.runtime.getURL('icons/action/default/icon32-default.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/default/icon36-default.png'),
|
'36': browser.runtime.getURL('icons/action/default/icon36-default.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/default/icon38-default.png'),
|
'38': browser.runtime.getURL('icons/action/default/icon38-default.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/default/icon64-default.png')
|
'64': browser.runtime.getURL('icons/action/default/icon64-default.png')
|
||||||
},
|
},
|
||||||
'Disabled': {
|
'Disabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/default/icon16-disabled.png'),
|
'16': browser.runtime.getURL('icons/action/default/icon16-disabled.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/default/icon18-disabled.png'),
|
'18': browser.runtime.getURL('icons/action/default/icon18-disabled.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/default/icon19-disabled.png'),
|
'19': browser.runtime.getURL('icons/action/default/icon19-disabled.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/default/icon32-disabled.png'),
|
'32': browser.runtime.getURL('icons/action/default/icon32-disabled.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/default/icon36-disabled.png'),
|
'36': browser.runtime.getURL('icons/action/default/icon36-disabled.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/default/icon38-disabled.png'),
|
'38': browser.runtime.getURL('icons/action/default/icon38-disabled.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/default/icon64-disabled.png')
|
'64': browser.runtime.getURL('icons/action/default/icon64-disabled.png')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Light': {
|
'Light': {
|
||||||
'Enabled': {
|
'Enabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/light/icon16-default.png'),
|
'16': browser.runtime.getURL('icons/action/light/icon16-default.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/light/icon18-default.png'),
|
'18': browser.runtime.getURL('icons/action/light/icon18-default.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/light/icon19-default.png'),
|
'19': browser.runtime.getURL('icons/action/light/icon19-default.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/light/icon32-default.png'),
|
'32': browser.runtime.getURL('icons/action/light/icon32-default.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/light/icon36-default.png'),
|
'36': browser.runtime.getURL('icons/action/light/icon36-default.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/light/icon38-default.png'),
|
'38': browser.runtime.getURL('icons/action/light/icon38-default.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/light/icon64-default.png')
|
'64': browser.runtime.getURL('icons/action/light/icon64-default.png')
|
||||||
},
|
},
|
||||||
'Disabled': {
|
'Disabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/light/icon16-disabled.png'),
|
'16': browser.runtime.getURL('icons/action/light/icon16-disabled.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/light/icon18-disabled.png'),
|
'18': browser.runtime.getURL('icons/action/light/icon18-disabled.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/light/icon19-disabled.png'),
|
'19': browser.runtime.getURL('icons/action/light/icon19-disabled.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/light/icon32-disabled.png'),
|
'32': browser.runtime.getURL('icons/action/light/icon32-disabled.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/light/icon36-disabled.png'),
|
'36': browser.runtime.getURL('icons/action/light/icon36-disabled.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/light/icon38-disabled.png'),
|
'38': browser.runtime.getURL('icons/action/light/icon38-disabled.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/light/icon64-disabled.png')
|
'64': browser.runtime.getURL('icons/action/light/icon64-disabled.png')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'Grey': {
|
'Grey': {
|
||||||
'Enabled': {
|
'Enabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/grey/icon16-default.png'),
|
'16': browser.runtime.getURL('icons/action/grey/icon16-default.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/grey/icon18-default.png'),
|
'18': browser.runtime.getURL('icons/action/grey/icon18-default.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/grey/icon19-default.png'),
|
'19': browser.runtime.getURL('icons/action/grey/icon19-default.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/grey/icon32-default.png'),
|
'32': browser.runtime.getURL('icons/action/grey/icon32-default.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/grey/icon36-default.png'),
|
'36': browser.runtime.getURL('icons/action/grey/icon36-default.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/grey/icon38-default.png'),
|
'38': browser.runtime.getURL('icons/action/grey/icon38-default.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/grey/icon64-default.png')
|
'64': browser.runtime.getURL('icons/action/grey/icon64-default.png')
|
||||||
},
|
},
|
||||||
'Disabled': {
|
'Disabled': {
|
||||||
'16': chrome.runtime.getURL('icons/action/grey/icon16-disabled.png'),
|
'16': browser.runtime.getURL('icons/action/grey/icon16-disabled.png'),
|
||||||
'18': chrome.runtime.getURL('icons/action/grey/icon18-disabled.png'),
|
'18': browser.runtime.getURL('icons/action/grey/icon18-disabled.png'),
|
||||||
'19': chrome.runtime.getURL('icons/action/grey/icon19-disabled.png'),
|
'19': browser.runtime.getURL('icons/action/grey/icon19-disabled.png'),
|
||||||
'32': chrome.runtime.getURL('icons/action/grey/icon32-disabled.png'),
|
'32': browser.runtime.getURL('icons/action/grey/icon32-disabled.png'),
|
||||||
'36': chrome.runtime.getURL('icons/action/grey/icon36-disabled.png'),
|
'36': browser.runtime.getURL('icons/action/grey/icon36-disabled.png'),
|
||||||
'38': chrome.runtime.getURL('icons/action/grey/icon38-disabled.png'),
|
'38': browser.runtime.getURL('icons/action/grey/icon38-disabled.png'),
|
||||||
'64': chrome.runtime.getURL('icons/action/grey/icon64-disabled.png')
|
'64': browser.runtime.getURL('icons/action/grey/icon64-disabled.png')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -282,17 +282,17 @@ const MaterialIcons = {
|
||||||
const Links = {
|
const Links = {
|
||||||
'CODEBERG_HTML_FILTER': 'https://codeberg.org/nobody/LocalCDN/wiki/Home#user-content-7-a-website-looks-weird-or-cannot-be-used-if-i-deactivate-localcdn-everything-works-what-is-the-problem',
|
'CODEBERG_HTML_FILTER': 'https://codeberg.org/nobody/LocalCDN/wiki/Home#user-content-7-a-website-looks-weird-or-cannot-be-used-if-i-deactivate-localcdn-everything-works-what-is-the-problem',
|
||||||
'CODEBERG_RULESET': 'https://codeberg.org/nobody/LocalCDN/wiki/Home#user-content-6-why-do-i-need-this-rule-generator-i-use-an-adblocker-and-want-to-import-these-rules-how-does-it-work',
|
'CODEBERG_RULESET': 'https://codeberg.org/nobody/LocalCDN/wiki/Home#user-content-6-why-do-i-need-this-rule-generator-i-use-an-adblocker-and-want-to-import-these-rules-how-does-it-work',
|
||||||
'WELCOME': chrome.runtime.getURL('pages/welcome/welcome.html'),
|
'WELCOME': browser.runtime.getURL('pages/welcome/welcome.html'),
|
||||||
'DONATE': chrome.runtime.getURL('pages/donate/donate.html'),
|
'DONATE': browser.runtime.getURL('pages/donate/donate.html'),
|
||||||
'CHANGELOG': chrome.runtime.getURL('pages/updates/updates.html'),
|
'CHANGELOG': browser.runtime.getURL('pages/updates/updates.html'),
|
||||||
'FAQ': chrome.runtime.getURL('pages/help/help.html'),
|
'FAQ': browser.runtime.getURL('pages/help/help.html'),
|
||||||
'FAQ_HTML_FILTER': chrome.runtime.getURL('pages/help/help.html#html-filter'),
|
'FAQ_HTML_FILTER': browser.runtime.getURL('pages/help/help.html#html-filter'),
|
||||||
'STATISTICS': chrome.runtime.getURL('pages/statistics/statistics.html'),
|
'STATISTICS': browser.runtime.getURL('pages/statistics/statistics.html'),
|
||||||
'LOCALCDN_TEST': 'https://www.localcdn.org/test',
|
'LOCALCDN_TEST': 'https://www.localcdn.org/test',
|
||||||
'LOCALCDN_TEST_WEBSITE': 'https://www.localcdn.org/test/check',
|
'LOCALCDN_TEST_WEBSITE': 'https://www.localcdn.org/test/check',
|
||||||
'WEBLATE': 'https://hosted.weblate.org/projects/localcdn/localcdn/',
|
'WEBLATE': 'https://hosted.weblate.org/projects/localcdn/localcdn/',
|
||||||
'LOGGING': chrome.runtime.getURL('pages/logging/logging.html'),
|
'LOGGING': browser.runtime.getURL('pages/logging/logging.html'),
|
||||||
'FAQ_PERMISSION': chrome.runtime.getURL('pages/help/help.html#permission'),
|
'FAQ_PERMISSION': browser.runtime.getURL('pages/help/help.html#permission'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const CDNs = {
|
const CDNs = {
|
||||||
|
|
|
@ -33,7 +33,7 @@ fileGuard._startListening = function () {
|
||||||
let randomHexString = helpers.generateRandomHexString(24);
|
let randomHexString = helpers.generateRandomHexString(24);
|
||||||
fileGuard.secret = `?_=${randomHexString}`;
|
fileGuard.secret = `?_=${randomHexString}`;
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
fileGuard._verifyRequest,
|
fileGuard._verifyRequest,
|
||||||
{'urls': [fileGuard.path + Address.ANY_PATH]},
|
{'urls': [fileGuard.path + Address.ANY_PATH]},
|
||||||
[WebRequest.BLOCKING]
|
[WebRequest.BLOCKING]
|
||||||
|
@ -42,7 +42,7 @@ fileGuard._startListening = function () {
|
||||||
|
|
||||||
fileGuard._verifyRequest = function (requestDetails) {
|
fileGuard._verifyRequest = function (requestDetails) {
|
||||||
|
|
||||||
let redirectUrl = chrome.runtime.getURL(Address.ROOT_PATH);
|
let redirectUrl = browser.runtime.getURL(Address.ROOT_PATH);
|
||||||
|
|
||||||
if (!requestDetails.url.endsWith(fileGuard.secret)) {
|
if (!requestDetails.url.endsWith(fileGuard.secret)) {
|
||||||
return {redirectUrl};
|
return {redirectUrl};
|
||||||
|
@ -54,7 +54,7 @@ fileGuard._verifyRequest = function (requestDetails) {
|
||||||
* Initializations
|
* Initializations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fileGuard.path = chrome.runtime.getURL(Address.RESOURCE_PATH);
|
fileGuard.path = browser.runtime.getURL(Address.RESOURCE_PATH);
|
||||||
fileGuard.secret = '';
|
fileGuard.secret = '';
|
||||||
|
|
||||||
if (fileGuard.path.startsWith(Address.CHROME_EXTENSION)) {
|
if (fileGuard.path.startsWith(Address.CHROME_EXTENSION)) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
|
||||||
source = helpers.extractDomainFromUrl(tab.url, true);
|
source = helpers.extractDomainFromUrl(tab.url, true);
|
||||||
resource = tab.url;
|
resource = tab.url;
|
||||||
return {
|
return {
|
||||||
'redirectUrl': chrome.runtime.getURL(`resources/blocked/index.html?source=${source}&resource=${resource}`)
|
'redirectUrl': browser.runtime.getURL(`resources/blocked/index.html?source=${source}&resource=${resource}`)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +92,13 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
|
||||||
isGoogleFont = requestAnalyzer.isGoogleFont(targetDomain);
|
isGoogleFont = requestAnalyzer.isGoogleFont(targetDomain);
|
||||||
isGoogleMaterialIcons = requestAnalyzer.isGoogleMaterialIcons(requestDetails.url);
|
isGoogleMaterialIcons = requestAnalyzer.isGoogleMaterialIcons(requestDetails.url);
|
||||||
|
|
||||||
if (BrowserType.FIREFOX && isGoogleFont && !isGoogleMaterialIcons) {
|
if (isGoogleFont && !isGoogleMaterialIcons) {
|
||||||
initiatorDomain = helpers.extractDomainFromUrl(tab.url, true);
|
initiatorDomain = helpers.extractDomainFromUrl(tab.url, true);
|
||||||
isListed = helpers.checkAllowlisted(initiatorDomain, interceptor.allowedDomainsGoogleFonts);
|
isListed = helpers.checkAllowlisted(initiatorDomain, interceptor.allowedDomainsGoogleFonts);
|
||||||
// Check if the website is allowed to load Google Fonts
|
// Check if the website is allowed to load Google Fonts
|
||||||
if (interceptor.blockGoogleFonts === true && isListed === false) {
|
if (interceptor.blockGoogleFonts === true && isListed === false) {
|
||||||
return {
|
return {
|
||||||
'redirectUrl': chrome.runtime.getURL('resources/google-fonts-placeholder.css')
|
'redirectUrl': browser.runtime.getURL('resources/google-fonts-placeholder.css')
|
||||||
};
|
};
|
||||||
} else if (interceptor.blockGoogleFonts === false || isListed === true) {
|
} else if (interceptor.blockGoogleFonts === false || isListed === true) {
|
||||||
return {
|
return {
|
||||||
|
@ -118,7 +118,7 @@ interceptor.handleRequest = function (requestDetails, tabIdentifier, tab) {
|
||||||
log.append(tab.url, requestDetails.url, targetDetails.path, false, iframe);
|
log.append(tab.url, requestDetails.url, targetDetails.path, false, iframe);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'redirectUrl': chrome.runtime.getURL(targetDetails.path + fileGuard.secret)
|
'redirectUrl': browser.runtime.getURL(targetDetails.path + fileGuard.secret)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -192,4 +192,4 @@ interceptor._isBadResource = function (requestUrl) {
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(interceptor._handleStorageChanged);
|
browser.storage.onChanged.addListener(interceptor._handleStorageChanged);
|
||||||
|
|
22
core/main.js
22
core/main.js
|
@ -62,7 +62,7 @@ main._initializeSettings = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.disablePrefetch !== false) {
|
if (items.disablePrefetch !== false) {
|
||||||
chrome.privacy.network.networkPredictionEnabled.set({
|
browser.privacy.network.networkPredictionEnabled.set({
|
||||||
'value': false
|
'value': false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -96,18 +96,18 @@ main._initializeSettings = function () {
|
||||||
main._showReleaseNotes = function (details) {
|
main._showReleaseNotes = function (details) {
|
||||||
storageManager.checkStorageType();
|
storageManager.checkStorageType();
|
||||||
|
|
||||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
if (details.reason === browser.runtime.OnInstalledReason.INSTALL) {
|
||||||
storageManager.type.set({
|
storageManager.type.set({
|
||||||
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
|
[Setting.LAST_MAPPING_UPDATE]: mappings.lastMappingUpdate
|
||||||
}, function () {
|
}, function () {
|
||||||
if (details.temporary !== true) {
|
if (details.temporary !== true) {
|
||||||
chrome.tabs.create({
|
browser.tabs.create({
|
||||||
'url': chrome.runtime.getURL('pages/welcome/welcome.html'),
|
'url': browser.runtime.getURL('pages/welcome/welcome.html'),
|
||||||
'active': true
|
'active': true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
} else if (details.reason === browser.runtime.OnInstalledReason.UPDATE) {
|
||||||
storageManager.type.get(null, function (items) {
|
storageManager.type.get(null, function (items) {
|
||||||
let mappingUpdate = items.lastMappingUpdate !== mappings.lastMappingUpdate;
|
let mappingUpdate = items.lastMappingUpdate !== mappings.lastMappingUpdate;
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ main._showReleaseNotes = function (details) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mappingUpdate && items.updateNotification === 1) || items.updateNotification === 2) {
|
if ((mappingUpdate && items.updateNotification === 1) || items.updateNotification === 2) {
|
||||||
chrome.tabs.create({
|
browser.tabs.create({
|
||||||
'url': chrome.runtime.getURL(`pages/updates/updates.html?mappingupdate=${mappingUpdate}`),
|
'url': browser.runtime.getURL(`pages/updates/updates.html?mappingupdate=${mappingUpdate}`),
|
||||||
'active': false
|
'active': false
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,8 +152,8 @@ main._showReleaseNotes = function (details) {
|
||||||
|
|
||||||
main._permissionStatusListener = function (e) {
|
main._permissionStatusListener = function (e) {
|
||||||
if (e.permissions.includes('<all_urls>')) {
|
if (e.permissions.includes('<all_urls>')) {
|
||||||
chrome.tabs.create({
|
browser.tabs.create({
|
||||||
'url': chrome.runtime.getURL('pages/info/info.html'),
|
'url': browser.runtime.getURL('pages/info/info.html'),
|
||||||
'active': true
|
'active': true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,6 @@ main._permissionStatusListener = function (e) {
|
||||||
/**
|
/**
|
||||||
* Initializations
|
* Initializations
|
||||||
*/
|
*/
|
||||||
chrome.runtime.onInstalled.addListener(main._showReleaseNotes);
|
browser.runtime.onInstalled.addListener(main._showReleaseNotes);
|
||||||
chrome.permissions.onRemoved.addListener(main._permissionStatusListener);
|
browser.permissions.onRemoved.addListener(main._permissionStatusListener);
|
||||||
main._initializeSettings();
|
main._initializeSettings();
|
||||||
|
|
|
@ -28,13 +28,6 @@ var manipulateDOM = {};
|
||||||
|
|
||||||
manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
|
manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
|
||||||
|
|
||||||
if (!BrowserType.FIREFOX) {
|
|
||||||
// Chromium (and other) browsers do not support webRequest.filterResponseData
|
|
||||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=487422
|
|
||||||
console.warn('[ LocalCDN ] browser.webRequest.filterResponseData not supported by your browser.');
|
|
||||||
log.append(details.url, '-', 'browser.webRequest.filterResponseData not supported by your browser', true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (details.statusCode === 200) {
|
if (details.statusCode === 200) {
|
||||||
let initiatorDomain, header;
|
let initiatorDomain, header;
|
||||||
|
|
||||||
|
@ -172,7 +165,7 @@ let cdnDomainsRE = new RegExp(`//(${Object.keys(mappings.cdn).map((m) => m.repla
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chrome.webRequest.onHeadersReceived.addListener(
|
browser.webRequest.onHeadersReceived.addListener(
|
||||||
manipulateDOM._removeCrossOriginAndIntegrityAttr,
|
manipulateDOM._removeCrossOriginAndIntegrityAttr,
|
||||||
{'types': [WebRequestType.MAIN_FRAME, WebRequestType.SUB_FRAME], 'urls': [Address.ANY]},
|
{'types': [WebRequestType.MAIN_FRAME, WebRequestType.SUB_FRAME], 'urls': [Address.ANY]},
|
||||||
[WebRequest.BLOCKING, WebRequest.RESPONSE_HEADERS]
|
[WebRequest.BLOCKING, WebRequest.RESPONSE_HEADERS]
|
||||||
|
|
|
@ -1230,13 +1230,6 @@ mappings.cdn['cdn.bootcdn.net'] = mappings.cdn['cdnjs.cloudflare.com'];
|
||||||
mappings.cdn['fonts.gstatic.com'] = mappings.cdn['fonts.googleapis.com'];
|
mappings.cdn['fonts.gstatic.com'] = mappings.cdn['fonts.googleapis.com'];
|
||||||
|
|
||||||
|
|
||||||
// Remove Google Fonts Endpoints for Chromium browsers (https://codeberg.org/nobody/LocalCDN/issues/1085)
|
|
||||||
if (!BrowserType.FIREFOX) {
|
|
||||||
delete mappings.cdn['fonts.gstatic.com'];
|
|
||||||
delete mappings.cdn['fonts.googleapis.com'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of CNAME CDNs
|
* List of CNAME CDNs
|
||||||
* https://codeberg.org/nobody/LocalCDN/issues/816
|
* https://codeberg.org/nobody/LocalCDN/issues/816
|
||||||
|
|
|
@ -121,4 +121,4 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(messenger._handleMessageReceived);
|
browser.runtime.onMessage.addListener(messenger._handleMessageReceived);
|
||||||
|
|
|
@ -50,16 +50,6 @@ requestAnalyzer.isValidCandidate = function (requestDetails, tabDetails) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font Awesome injections in Chromium deactivated (https://gitlab.com/nobody42/localcdn/-/issues/67)
|
|
||||||
if (!BrowserType.FIREFOX) {
|
|
||||||
let requestType = requestAnalyzer.chromeSupport(requestDetails.url);
|
|
||||||
if (requestType !== '') {
|
|
||||||
console.warn(`${LogString.PREFIX} ${requestType} ${LogString.NOT_SUPPORTED}`);
|
|
||||||
log.append(tabDetails.url, requestDetails.url, `${requestType} ${LogString.NOT_SUPPORTED}`, true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ignore requests if website is 'yandex.com' and CDN is 'yastatic.net', because website and CDN are the same.
|
// Ignore requests if website is 'yandex.com' and CDN is 'yastatic.net', because website and CDN are the same.
|
||||||
if (tabDetails.url.includes('yandex.com') && requestDetails.url.includes('yastatic.net')) {
|
if (tabDetails.url.includes('yandex.com') && requestDetails.url.includes('yastatic.net')) {
|
||||||
log.append(tabDetails.url, requestDetails.url, LogString.YANDEX, true);
|
log.append(tabDetails.url, requestDetails.url, LogString.YANDEX, true);
|
||||||
|
@ -334,5 +324,5 @@ requestAnalyzer._applyManipulateDOMDomains();
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(requestAnalyzer._applyAllowlistedDomains);
|
browser.storage.onChanged.addListener(requestAnalyzer._applyAllowlistedDomains);
|
||||||
chrome.storage.onChanged.addListener(requestAnalyzer._applyManipulateDOMDomains);
|
browser.storage.onChanged.addListener(requestAnalyzer._applyManipulateDOMDomains);
|
||||||
|
|
|
@ -21,36 +21,24 @@
|
||||||
var requestSanitizer = {};
|
var requestSanitizer = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preparation
|
|
||||||
* https://codeberg.org/nobody/LocalCDN/issues/442
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable indent */
|
|
||||||
const ExtraInfoSpec = BrowserType.FIREFOX
|
|
||||||
? [WebRequest.BLOCKING, WebRequest.HEADERS]
|
|
||||||
: [WebRequest.BLOCKING, WebRequest.HEADERS, WebRequest.EXTRA_HEADERS];
|
|
||||||
/* eslint-enable indent */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Methods
|
* Public Methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
requestSanitizer.enable = function () {
|
requestSanitizer.enable = function () {
|
||||||
let onBeforeSendHeaders = chrome.webRequest.onBeforeSendHeaders;
|
let onBeforeSendHeaders = browser.webRequest.onBeforeSendHeaders;
|
||||||
|
|
||||||
onBeforeSendHeaders.addListener(requestSanitizer._stripMetadata, {
|
onBeforeSendHeaders.addListener(requestSanitizer._stripMetadata, {
|
||||||
'urls': stateManager.validHosts
|
'urls': stateManager.validHosts
|
||||||
}, ExtraInfoSpec);
|
}, [WebRequest.BLOCKING, WebRequest.HEADERS]);
|
||||||
};
|
};
|
||||||
|
|
||||||
requestSanitizer.disable = function () {
|
requestSanitizer.disable = function () {
|
||||||
let onBeforeSendHeaders = chrome.webRequest.onBeforeSendHeaders;
|
let onBeforeSendHeaders = browser.webRequest.onBeforeSendHeaders;
|
||||||
|
|
||||||
onBeforeSendHeaders.removeListener(requestSanitizer._stripMetadata, {
|
onBeforeSendHeaders.removeListener(requestSanitizer._stripMetadata, {
|
||||||
'urls': stateManager.validHosts
|
'urls': stateManager.validHosts
|
||||||
}, ExtraInfoSpec);
|
}, [WebRequest.BLOCKING, WebRequest.HEADERS]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ stateManager.registerInjection = function (tabIdentifier, injection, url) {
|
||||||
missingCount = registeredTab.missing || 0;
|
missingCount = registeredTab.missing || 0;
|
||||||
|
|
||||||
if (injectionCount > 0) {
|
if (injectionCount > 0) {
|
||||||
chrome.action.setTitle({
|
browser.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': `LocalCDN (${injectionCount})`
|
'title': `LocalCDN (${injectionCount})`
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,7 @@ stateManager.registerInjection = function (tabIdentifier, injection, url) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.AMOUNT_INJECTED]: ++storageManager.amountInjected
|
[Setting.AMOUNT_INJECTED]: ++storageManager.amountInjected
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ stateManager._createTab = function (tab) {
|
||||||
'urls': stateManager.validHosts
|
'urls': stateManager.validHosts
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
|
browser.webRequest.onBeforeRequest.addListener(function (requestDetails) {
|
||||||
tab = stateManager.tabs[tabIdentifier].details || {};
|
tab = stateManager.tabs[tabIdentifier].details || {};
|
||||||
return interceptor.handleRequest(requestDetails, tabIdentifier, tab);
|
return interceptor.handleRequest(requestDetails, tabIdentifier, tab);
|
||||||
}, requestFilters, [WebRequest.BLOCKING]);
|
}, requestFilters, [WebRequest.BLOCKING]);
|
||||||
|
@ -185,14 +185,14 @@ stateManager._updateTab = function (details) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.action.setTitle({
|
browser.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': 'LocalCDN (0)'
|
'title': 'LocalCDN (0)'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (domainIsAllowlisted) {
|
if (domainIsAllowlisted) {
|
||||||
stateManager._setIconDisabled(tabIdentifier);
|
stateManager._setIconDisabled(tabIdentifier);
|
||||||
chrome.action.setTitle({
|
browser.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': 'LocalCDN (–)'
|
'title': 'LocalCDN (–)'
|
||||||
});
|
});
|
||||||
|
@ -212,7 +212,7 @@ stateManager._handleStorageChanged = function (changes) {
|
||||||
if (Setting.SHOW_ICON_BADGE in changes) {
|
if (Setting.SHOW_ICON_BADGE in changes) {
|
||||||
stateManager.showIconBadge = changes.showIconBadge.newValue;
|
stateManager.showIconBadge = changes.showIconBadge.newValue;
|
||||||
if (changes.showIconBadge.newValue !== true) {
|
if (changes.showIconBadge.newValue !== true) {
|
||||||
chrome.tabs.query({}, function (tabs) {
|
browser.tabs.query({}, function (tabs) {
|
||||||
tabs.forEach(stateManager._removeIconBadgeFromTab);
|
tabs.forEach(stateManager._removeIconBadgeFromTab);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ for (let mapping in mappings.cdn) {
|
||||||
stateManager.validHosts.push(supportedHost);
|
stateManager.validHosts.push(supportedHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.tabs.query({}, function (tabs) {
|
browser.tabs.query({}, function (tabs) {
|
||||||
tabs.forEach(stateManager._createTab);
|
tabs.forEach(stateManager._createTab);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ storageManager.type.get([
|
||||||
stateManager.amountInjected = items.amountInjected;
|
stateManager.amountInjected = items.amountInjected;
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.local.get([Setting.INTERNAL_STATISTICS], function (items) {
|
browser.storage.local.get([Setting.INTERNAL_STATISTICS], function (items) {
|
||||||
stateManager.internalStatistics = items.internalStatistics;
|
stateManager.internalStatistics = items.internalStatistics;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -340,10 +340,10 @@ chrome.storage.local.get([Setting.INTERNAL_STATISTICS], function (items) {
|
||||||
* Event Handlers
|
* Event Handlers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chrome.tabs.onCreated.addListener(stateManager._createTab);
|
browser.tabs.onCreated.addListener(stateManager._createTab);
|
||||||
chrome.tabs.onRemoved.addListener(stateManager._removeTab);
|
browser.tabs.onRemoved.addListener(stateManager._removeTab);
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
|
browser.webRequest.onBeforeRequest.addListener(function (requestDetails) {
|
||||||
if (requestDetails.tabId !== -1 && stateManager.tabs[requestDetails.tabId]) {
|
if (requestDetails.tabId !== -1 && stateManager.tabs[requestDetails.tabId]) {
|
||||||
stateManager.tabs[requestDetails.tabId].details = {
|
stateManager.tabs[requestDetails.tabId].details = {
|
||||||
'url': requestDetails.url
|
'url': requestDetails.url
|
||||||
|
@ -351,17 +351,17 @@ chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
|
||||||
}
|
}
|
||||||
}, {'types': [WebRequestType.MAIN_FRAME], 'urls': [Address.ANY]}, [WebRequest.BLOCKING]);
|
}, {'types': [WebRequestType.MAIN_FRAME], 'urls': [Address.ANY]}, [WebRequest.BLOCKING]);
|
||||||
|
|
||||||
chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, {
|
browser.webNavigation.onCommitted.addListener(stateManager._updateTab, {
|
||||||
'url': [{'urlContains': ':'}]
|
'url': [{'urlContains': ':'}]
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.webRequest.onErrorOccurred.addListener(function (requestDetails) {
|
browser.webRequest.onErrorOccurred.addListener(function (requestDetails) {
|
||||||
if (stateManager.requests[requestDetails.requestId]) {
|
if (stateManager.requests[requestDetails.requestId]) {
|
||||||
delete stateManager.requests[requestDetails.requestId];
|
delete stateManager.requests[requestDetails.requestId];
|
||||||
}
|
}
|
||||||
}, {'urls': [Address.ANY]});
|
}, {'urls': [Address.ANY]});
|
||||||
|
|
||||||
chrome.webRequest.onBeforeRedirect.addListener(function (requestDetails) {
|
browser.webRequest.onBeforeRedirect.addListener(function (requestDetails) {
|
||||||
let knownRequest = stateManager.requests[requestDetails.requestId];
|
let knownRequest = stateManager.requests[requestDetails.requestId];
|
||||||
if (knownRequest) {
|
if (knownRequest) {
|
||||||
stateManager.registerInjection(
|
stateManager.registerInjection(
|
||||||
|
@ -373,4 +373,4 @@ chrome.webRequest.onBeforeRedirect.addListener(function (requestDetails) {
|
||||||
}
|
}
|
||||||
}, {'urls': [Address.ANY]});
|
}, {'urls': [Address.ANY]});
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(stateManager._handleStorageChanged);
|
browser.storage.onChanged.addListener(stateManager._handleStorageChanged);
|
||||||
|
|
|
@ -34,11 +34,11 @@ var storageManager = {};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
storageManager.checkStorageType = function () {
|
storageManager.checkStorageType = function () {
|
||||||
chrome.storage.local.get([Setting.STORAGE_TYPE], function (items) {
|
browser.storage.local.get([Setting.STORAGE_TYPE], function (items) {
|
||||||
if (items.storageType === 'sync') {
|
if (items.storageType === 'sync') {
|
||||||
storageManager.type = chrome.storage.sync;
|
storageManager.type = browser.storage.sync;
|
||||||
} else {
|
} else {
|
||||||
storageManager.type = chrome.storage.local;
|
storageManager.type = browser.storage.local;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -49,14 +49,14 @@ storageManager.migrateData = function (target) {
|
||||||
syncFetch = false;
|
syncFetch = false;
|
||||||
|
|
||||||
if (target === 'local') {
|
if (target === 'local') {
|
||||||
storageSource = chrome.storage.sync;
|
storageSource = browser.storage.sync;
|
||||||
storageDestination = chrome.storage.local;
|
storageDestination = browser.storage.local;
|
||||||
} else if (target === 'sync') {
|
} else if (target === 'sync') {
|
||||||
storageSource = chrome.storage.local;
|
storageSource = browser.storage.local;
|
||||||
storageDestination = chrome.storage.sync;
|
storageDestination = browser.storage.sync;
|
||||||
} else if (target === 'sync-fetch') {
|
} else if (target === 'sync-fetch') {
|
||||||
storageSource = chrome.storage.sync;
|
storageSource = browser.storage.sync;
|
||||||
storageDestination = chrome.storage.sync;
|
storageDestination = browser.storage.sync;
|
||||||
target = 'sync';
|
target = 'sync';
|
||||||
syncFetch = true;
|
syncFetch = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,7 @@ storageManager.migrateData = function (target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
storageSource.get(null, function (data) {
|
storageSource.get(null, function (data) {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.AMOUNT_INJECTED]: data.amountInjected,
|
[Setting.AMOUNT_INJECTED]: data.amountInjected,
|
||||||
[Setting.INTERNAL_STATISTICS]: data.internalStatistics,
|
[Setting.INTERNAL_STATISTICS]: data.internalStatistics,
|
||||||
[Setting.INTERNAL_STATISTICS_DATA]: data.internalStatisticsData,
|
[Setting.INTERNAL_STATISTICS_DATA]: data.internalStatisticsData,
|
||||||
|
@ -92,7 +92,7 @@ storageManager.migrateData = function (target) {
|
||||||
[Setting.BADGE_HTML_FILTER_TEXT_COLOR]: data.badgeHTMLfilterTextColor
|
[Setting.BADGE_HTML_FILTER_TEXT_COLOR]: data.badgeHTMLfilterTextColor
|
||||||
});
|
});
|
||||||
if (syncFetch === true) {
|
if (syncFetch === true) {
|
||||||
chrome.runtime.reload();
|
browser.runtime.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -145,9 +145,9 @@ storageManager.handleImportFilePicker = function () {
|
||||||
storageManager._handleStorageChanged = function (type) {
|
storageManager._handleStorageChanged = function (type) {
|
||||||
if (Setting.STORAGE_TYPE in type) {
|
if (Setting.STORAGE_TYPE in type) {
|
||||||
if (type.storageType.newValue === 'sync') {
|
if (type.storageType.newValue === 'sync') {
|
||||||
storageManager.type = chrome.storage.sync;
|
storageManager.type = browser.storage.sync;
|
||||||
} else {
|
} else {
|
||||||
storageManager.type = chrome.storage.local;
|
storageManager.type = browser.storage.local;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -196,15 +196,15 @@ storageManager._validation = function (content) {
|
||||||
// Set default if not existing in file
|
// Set default if not existing in file
|
||||||
imported[key] = value;
|
imported[key] = value;
|
||||||
} else {
|
} else {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}\n\n${key}: ${content[key]}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}\n\n${key}: ${content[key]}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storageManager.type.set(imported);
|
storageManager.type.set(imported);
|
||||||
|
|
||||||
alert(chrome.i18n.getMessage('dialogImportSuccessful'));
|
alert(browser.i18n.getMessage('dialogImportSuccessful'));
|
||||||
chrome.runtime.reload();
|
browser.runtime.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
storageManager._validateDomainsAndStatistics = function (type, obj) {
|
storageManager._validateDomainsAndStatistics = function (type, obj) {
|
||||||
|
@ -216,7 +216,7 @@ storageManager._validateDomainsAndStatistics = function (type, obj) {
|
||||||
if (((/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}/).test(key) || key === '') && value === true) {
|
if (((/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}/).test(key) || key === '') && value === true) {
|
||||||
valid[key] = value;
|
valid[key] = value;
|
||||||
} else {
|
} else {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${key}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${key}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ storageManager._validateDomainsAndStatistics = function (type, obj) {
|
||||||
for (const [name, counter] of Object.entries(category)) {
|
for (const [name, counter] of Object.entries(category)) {
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
if (!(/resources\/[0-9a-z.-]+\/((?:\d{1,2}\.){1,3}\d{1,2})?.*\.(css|jsm)/).test(name) && !storageManager._validateNumbers(counter)) {
|
if (!(/resources\/[0-9a-z.-]+\/((?:\d{1,2}\.){1,3}\d{1,2})?.*\.(css|jsm)/).test(name) && !storageManager._validateNumbers(counter)) {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${name}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${name}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,23 +236,23 @@ storageManager._validateDomainsAndStatistics = function (type, obj) {
|
||||||
for (const [name, counter] of Object.entries(category)) {
|
for (const [name, counter] of Object.entries(category)) {
|
||||||
// eslint-disable-next-line no-useless-escape, max-len
|
// eslint-disable-next-line no-useless-escape, max-len
|
||||||
if (!(/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}/).test(name) && !storageManager._validateNumbers(counter)) {
|
if (!(/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,24}/).test(name) && !storageManager._validateNumbers(counter)) {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${name}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${name}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${type}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${type}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${date}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${date}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
valid = obj;
|
valid = obj;
|
||||||
} else {
|
} else {
|
||||||
alert(`${chrome.i18n.getMessage('dialogImportFailed')}: ${type}`);
|
alert(`${browser.i18n.getMessage('dialogImportFailed')}: ${type}`);
|
||||||
throw InvalidFile;
|
throw InvalidFile;
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
|
@ -284,8 +284,8 @@ storageManager._validateNumbers = function (value) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
storageManager.data = {};
|
storageManager.data = {};
|
||||||
storageManager.type = chrome.storage.local;
|
storageManager.type = browser.storage.local;
|
||||||
storageManager.amountInjected = 0;
|
storageManager.amountInjected = 0;
|
||||||
storageManager.statistics = {};
|
storageManager.statistics = {};
|
||||||
|
|
||||||
chrome.storage.onChanged.addListener(storageManager._handleStorageChanged);
|
browser.storage.onChanged.addListener(storageManager._handleStorageChanged);
|
||||||
|
|
|
@ -40,11 +40,11 @@ helpers.insertI18nContentIntoDocument = function (document) {
|
||||||
i18nElements.forEach(function (i18nElement) {
|
i18nElements.forEach(function (i18nElement) {
|
||||||
let i18nMessageName = i18nElement.getAttribute('data-i18n-content');
|
let i18nMessageName = i18nElement.getAttribute('data-i18n-content');
|
||||||
|
|
||||||
if (chrome.i18n.getMessage(i18nMessageName) !== '') {
|
if (browser.i18n.getMessage(i18nMessageName) !== '') {
|
||||||
if (i18nElement.type === 'button') {
|
if (i18nElement.type === 'button') {
|
||||||
i18nElement.value = chrome.i18n.getMessage(i18nMessageName);
|
i18nElement.value = browser.i18n.getMessage(i18nMessageName);
|
||||||
} else {
|
} else {
|
||||||
i18nElement.textContent = chrome.i18n.getMessage(i18nMessageName);
|
i18nElement.textContent = browser.i18n.getMessage(i18nMessageName);
|
||||||
}
|
}
|
||||||
i18nElement.setAttribute('dir', scriptDirection);
|
i18nElement.setAttribute('dir', scriptDirection);
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,7 @@ helpers.insertI18nTitlesIntoDocument = function (document) {
|
||||||
i18nElements.forEach(function (i18nElement) {
|
i18nElements.forEach(function (i18nElement) {
|
||||||
let i18nMessageName = i18nElement.getAttribute('data-i18n-title');
|
let i18nMessageName = i18nElement.getAttribute('data-i18n-title');
|
||||||
|
|
||||||
i18nElement.setAttribute('title', chrome.i18n.getMessage(i18nMessageName));
|
i18nElement.setAttribute('title', browser.i18n.getMessage(i18nMessageName));
|
||||||
i18nElement.setAttribute('dir', scriptDirection);
|
i18nElement.setAttribute('dir', scriptDirection);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -242,13 +242,13 @@ helpers.determineActiveTab = function () {
|
||||||
'currentWindow': true
|
'currentWindow': true
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.tabs.query(opt, function (tabs) {
|
browser.tabs.query(opt, function (tabs) {
|
||||||
if (tabs[0]) {
|
if (tabs[0]) {
|
||||||
resolve(tabs[0]);
|
resolve(tabs[0]);
|
||||||
} else {
|
} else {
|
||||||
opt = {'active': true};
|
opt = {'active': true};
|
||||||
|
|
||||||
chrome.tabs.query(opt, function () {
|
browser.tabs.query(opt, function () {
|
||||||
resolve(tabs[0]);
|
resolve(tabs[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
var permission = {};
|
var permission = {};
|
||||||
|
|
||||||
permission._onDocumentLoaded = function () {
|
permission._onDocumentLoaded = function () {
|
||||||
chrome.permissions.getAll(({origins}) => {
|
browser.permissions.getAll(({origins}) => {
|
||||||
if (origins.includes('<all_urls>')) {
|
if (origins.includes('<all_urls>')) {
|
||||||
document.getElementById('div-permission').hidden = true;
|
document.getElementById('div-permission').hidden = true;
|
||||||
document.getElementById('div-content').hidden = false;
|
document.getElementById('div-content').hidden = false;
|
||||||
|
@ -26,7 +26,7 @@ permission._onDocumentLoaded = function () {
|
||||||
document.getElementById('div-content').hidden = true;
|
document.getElementById('div-content').hidden = true;
|
||||||
console.error('[ LocalCDN ] missing permission');
|
console.error('[ LocalCDN ] missing permission');
|
||||||
document.getElementById('grant-permission').addEventListener('click', function () {
|
document.getElementById('grant-permission').addEventListener('click', function () {
|
||||||
chrome.permissions.request({'origins': ['<all_urls>']});
|
browser.permissions.request({'origins': ['<all_urls>']});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@ permission._removed = function () {
|
||||||
document.getElementById('div-content').hidden = true;
|
document.getElementById('div-content').hidden = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.permissions.onAdded.addListener(permission._added);
|
browser.permissions.onAdded.addListener(permission._added);
|
||||||
chrome.permissions.onRemoved.addListener(permission._removed);
|
browser.permissions.onRemoved.addListener(permission._removed);
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', permission._onDocumentLoaded);
|
document.addEventListener('DOMContentLoaded', permission._onDocumentLoaded);
|
||||||
|
|
|
@ -38,11 +38,6 @@ ruleGenerator.openRuleSet = function ({target}) {
|
||||||
textArea.style.display = 'block';
|
textArea.style.display = 'block';
|
||||||
btnCopy.style.display = 'block';
|
btnCopy.style.display = 'block';
|
||||||
|
|
||||||
if (!BrowserType.FIREFOX) {
|
|
||||||
delete urls['fonts.googleapis.com'];
|
|
||||||
delete urls['fonts.gstatic.com'];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const domain in urls) {
|
for (const domain in urls) {
|
||||||
if (key === 'uMatrix') {
|
if (key === 'uMatrix') {
|
||||||
content += `* ${domain} script allow\n`;
|
content += `* ${domain} script allow\n`;
|
||||||
|
|
|
@ -57,13 +57,13 @@ stats.setStats = function (injection) {
|
||||||
data[today] = newEntry;
|
data[today] = newEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.INTERNAL_STATISTICS_DATA]: data,
|
[Setting.INTERNAL_STATISTICS_DATA]: data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
stats.getStats = function () {
|
stats.getStats = function () {
|
||||||
chrome.storage.local.get([Setting.INTERNAL_STATISTICS_DATA], function (items) {
|
browser.storage.local.get([Setting.INTERNAL_STATISTICS_DATA], function (items) {
|
||||||
storageManager.statistics = items.internalStatisticsData || {};
|
storageManager.statistics = items.internalStatisticsData || {};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ var wrappers = {};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wrappers.setBadgeBackgroundColor = function (details) {
|
wrappers.setBadgeBackgroundColor = function (details) {
|
||||||
if (chrome.action.setBadgeBackgroundColor === undefined) {
|
if (browser.action.setBadgeBackgroundColor === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ wrappers.setBadgeBackgroundColor = function (details) {
|
||||||
};
|
};
|
||||||
|
|
||||||
wrappers.setBadgeTextColor = function (details) {
|
wrappers.setBadgeTextColor = function (details) {
|
||||||
if (chrome.action.setBadgeTextColor === undefined) {
|
if (browser.action.setBadgeTextColor === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ wrappers.setBadgeTextColor = function (details) {
|
||||||
};
|
};
|
||||||
|
|
||||||
wrappers.setBadgeText = function (tabId, text) {
|
wrappers.setBadgeText = function (tabId, text) {
|
||||||
if (chrome.action.setBadgeText !== undefined) {
|
if (browser.action.setBadgeText !== undefined) {
|
||||||
chrome.action.setBadgeText({
|
browser.action.setBadgeText({
|
||||||
'tabId': tabId,
|
'tabId': tabId,
|
||||||
'text': `${text}`
|
'text': `${text}`
|
||||||
});
|
});
|
||||||
|
@ -73,9 +73,9 @@ wrappers.setBadgeText = function (tabId, text) {
|
||||||
};
|
};
|
||||||
|
|
||||||
wrappers.setIcon = function (details, type) {
|
wrappers.setIcon = function (details, type) {
|
||||||
if (chrome.action.setIcon) {
|
if (browser.action.setIcon) {
|
||||||
details.path = IconType[details.path][type];
|
details.path = IconType[details.path][type];
|
||||||
chrome.action.setIcon(details);
|
browser.action.setIcon(details);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,15 +95,15 @@ wrappers.setBadgeColoring = function (tabId, value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chrome.action.setBadgeTextColor !== undefined) {
|
if (browser.action.setBadgeTextColor !== undefined) {
|
||||||
chrome.action.setBadgeTextColor({
|
browser.action.setBadgeTextColor({
|
||||||
'tabId': tabId,
|
'tabId': tabId,
|
||||||
'color': textColor
|
'color': textColor
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chrome.action.setBadgeBackgroundColor !== undefined) {
|
if (browser.action.setBadgeBackgroundColor !== undefined) {
|
||||||
chrome.action.setBadgeBackgroundColor({
|
browser.action.setBadgeBackgroundColor({
|
||||||
'tabId': tabId,
|
'tabId': tabId,
|
||||||
'color': backgroundColor
|
'color': backgroundColor
|
||||||
});
|
});
|
||||||
|
|
|
@ -87,7 +87,7 @@ logging._deleteLogs = function () {
|
||||||
'value': '',
|
'value': '',
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message);
|
browser.runtime.sendMessage(message);
|
||||||
logging._resfresh();
|
logging._resfresh();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -98,7 +98,7 @@ logging._getLoggingData = function () {
|
||||||
'topic': 'logs:get'
|
'topic': 'logs:get'
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (data) {
|
browser.runtime.sendMessage(message, function (data) {
|
||||||
logging._data = data['logs'];
|
logging._data = data['logs'];
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
|
@ -57,11 +57,6 @@ optionsAdvanced.init = function (opt) {
|
||||||
let blockMissing, blockGoogleFonts, allowedDomainsGoogleFonts, logging, domainsManipulateDOM,
|
let blockMissing, blockGoogleFonts, allowedDomainsGoogleFonts, logging, domainsManipulateDOM,
|
||||||
negateHtmlFilterList, changeBadgeColorMissingResources;
|
negateHtmlFilterList, changeBadgeColorMissingResources;
|
||||||
|
|
||||||
if (BrowserType.CHROMIUM) {
|
|
||||||
document.getElementById('html-filter-div').style.display = 'none';
|
|
||||||
document.getElementById('block-google-fonts').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('last-mapping-update').textContent += ` ${mappings.lastMappingUpdate}`;
|
document.getElementById('last-mapping-update').textContent += ` ${mappings.lastMappingUpdate}`;
|
||||||
|
|
||||||
blockMissing = options.getOptionElement(Setting.BLOCK_MISSING);
|
blockMissing = options.getOptionElement(Setting.BLOCK_MISSING);
|
||||||
|
|
|
@ -44,12 +44,6 @@ optionsInfo._renderCdnFrameworkSection = function () {
|
||||||
optionsInfo._listOfFrameworks[path[1]] = true;
|
optionsInfo._listOfFrameworks[path[1]] = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!BrowserType.FIREFOX) {
|
|
||||||
// Non-Firefox browser does not support Google Material Icons and Font Awesome
|
|
||||||
document.getElementById('unsupported-frameworks').style.display = 'block';
|
|
||||||
unsupportedFrameworks = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
optionsInfo._createList('cdn');
|
optionsInfo._createList('cdn');
|
||||||
document.getElementById('cdn').classList.add('btns-active');
|
document.getElementById('cdn').classList.add('btns-active');
|
||||||
|
|
||||||
|
@ -92,9 +86,7 @@ optionsInfo._createList = function (type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
list.forEach((elem) => {
|
list.forEach((elem) => {
|
||||||
if (!(BrowserType.CHROMIUM && (elem === 'fontawesome' || elem === 'google-material-design-icons'))) {
|
textArea.value += `${elem}\n`;
|
||||||
textArea.value += `${elem}\n`;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ var optionsOther = {};
|
||||||
optionsOther._renderIconSection = function (opt) {
|
optionsOther._renderIconSection = function (opt) {
|
||||||
let url, bgColor, txtColor, selectedIcon;
|
let url, bgColor, txtColor, selectedIcon;
|
||||||
|
|
||||||
if (!chrome.action.setIcon) {
|
if (!browser.action.setIcon) {
|
||||||
document.getElementById('icon-style-div').style.display = 'none';
|
document.getElementById('icon-style-div').style.display = 'none';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ optionsOther._renderIconSection = function (opt) {
|
||||||
} else if (selectedIcon === 'Light') {
|
} else if (selectedIcon === 'Light') {
|
||||||
document.getElementById('icon-light').checked = true;
|
document.getElementById('icon-light').checked = true;
|
||||||
}
|
}
|
||||||
url = chrome.runtime.getURL(`icons/action/${selectedIcon.toLowerCase()}/icon38-default.png`);
|
url = browser.runtime.getURL(`icons/action/${selectedIcon.toLowerCase()}/icon38-default.png`);
|
||||||
document.getElementById(BadgeSetting.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSetting.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
document.getElementById(BadgeSettingHTMLFilter.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSettingHTMLFilter.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
document.getElementById(BadgeSettingMissingResource.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSettingMissingResource.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
|
@ -91,7 +91,7 @@ optionsOther._renderStorageSection = function (opt) {
|
||||||
|
|
||||||
optionsOther._setIcon = function (optionValue) {
|
optionsOther._setIcon = function (optionValue) {
|
||||||
wrappers.setIcon({'path': optionValue}, 'Enabled');
|
wrappers.setIcon({'path': optionValue}, 'Enabled');
|
||||||
let url = chrome.runtime.getURL(`icons/action/${optionValue.toLowerCase()}/icon38-default.png`);
|
let url = browser.runtime.getURL(`icons/action/${optionValue.toLowerCase()}/icon38-default.png`);
|
||||||
document.getElementById(BadgeSetting.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSetting.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
document.getElementById(BadgeSettingHTMLFilter.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSettingHTMLFilter.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
document.getElementById(BadgeSettingMissingResource.HTML_ICON_BADGE_PREVIEW).src = url;
|
document.getElementById(BadgeSettingMissingResource.HTML_ICON_BADGE_PREVIEW).src = url;
|
||||||
|
@ -106,7 +106,7 @@ optionsOther._preSelectStorage = function (type) {
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsOther._onStorageOptionChanged = function ({target}) {
|
optionsOther._onStorageOptionChanged = function ({target}) {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.STORAGE_TYPE]: target.value,
|
[Setting.STORAGE_TYPE]: target.value,
|
||||||
});
|
});
|
||||||
if (target.value === 'local') {
|
if (target.value === 'local') {
|
||||||
|
@ -220,11 +220,6 @@ optionsOther._getBadgeElement = function (targetId) {
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsOther.init = function (opt) {
|
optionsOther.init = function (opt) {
|
||||||
if (BrowserType.CHROMIUM) {
|
|
||||||
document.getElementById('div-badged-text-color').style.display = 'none';
|
|
||||||
document.getElementById('html-div-badged-text-color').style.display = 'none';
|
|
||||||
document.getElementById('missing-div-badged-text-color').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('icon-default').addEventListener('change', options.onOptionChanged);
|
document.getElementById('icon-default').addEventListener('change', options.onOptionChanged);
|
||||||
document.getElementById('icon-grey').addEventListener('change', options.onOptionChanged);
|
document.getElementById('icon-grey').addEventListener('change', options.onOptionChanged);
|
||||||
|
|
|
@ -42,12 +42,7 @@ options._renderContents = function () {
|
||||||
options._renderLocaleNotice();
|
options._renderLocaleNotice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BrowserType.FIREFOX) {
|
document.getElementById('label-version').textContent = browser.runtime.getManifest().version;
|
||||||
document.getElementById('chromium-banner').style.display = 'block';
|
|
||||||
document.getElementById('div-html-badge').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('label-version').textContent = chrome.runtime.getManifest().version;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
options._renderOptionsPanel = function () {
|
options._renderOptionsPanel = function () {
|
||||||
|
@ -157,12 +152,12 @@ options._determineOptionValues = function () {
|
||||||
optionKeys = Object.keys(optionList);
|
optionKeys = Object.keys(optionList);
|
||||||
|
|
||||||
if (options._storageType === 'sync') {
|
if (options._storageType === 'sync') {
|
||||||
chrome.storage.sync.get(optionKeys, function (items) {
|
browser.storage.sync.get(optionKeys, function (items) {
|
||||||
options._optionValues = items;
|
options._optionValues = items;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
chrome.storage.local.get(optionKeys, function (items) {
|
browser.storage.local.get(optionKeys, function (items) {
|
||||||
options._optionValues = items;
|
options._optionValues = items;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -172,7 +167,7 @@ options._determineOptionValues = function () {
|
||||||
|
|
||||||
options._determineLocalOptionValues = function () {
|
options._determineLocalOptionValues = function () {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
chrome.storage.local.get([Setting.INTERNAL_STATISTICS, Setting.STORAGE_TYPE], function (items) {
|
browser.storage.local.get([Setting.INTERNAL_STATISTICS, Setting.STORAGE_TYPE], function (items) {
|
||||||
options._internalStatistics = items.internalStatistics;
|
options._internalStatistics = items.internalStatistics;
|
||||||
options._storageType = items.storageType;
|
options._storageType = items.storageType;
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -187,9 +182,9 @@ options.getOptionElement = function (optionKey) {
|
||||||
options._configureLinkPrefetching = function (value) {
|
options._configureLinkPrefetching = function (value) {
|
||||||
if (value === false) {
|
if (value === false) {
|
||||||
// Restore default values of related preference values.
|
// Restore default values of related preference values.
|
||||||
chrome.privacy.network.networkPredictionEnabled.clear({});
|
browser.privacy.network.networkPredictionEnabled.clear({});
|
||||||
} else {
|
} else {
|
||||||
chrome.privacy.network.networkPredictionEnabled.set({
|
browser.privacy.network.networkPredictionEnabled.set({
|
||||||
'value': false,
|
'value': false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -281,24 +276,24 @@ options.onOptionChanged = function ({target}) {
|
||||||
break;
|
break;
|
||||||
case Setting.LOGGING:
|
case Setting.LOGGING:
|
||||||
if (optionValue === false) {
|
if (optionValue === false) {
|
||||||
chrome.runtime.sendMessage({'topic': 'logs:delete', 'value': ''});
|
browser.runtime.sendMessage({'topic': 'logs:delete', 'value': ''});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options._storageType === 'sync' && optionKey !== 'internalStatistics') {
|
if (options._storageType === 'sync' && optionKey !== 'internalStatistics') {
|
||||||
chrome.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
[optionKey]: optionValue,
|
[optionKey]: optionValue,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[optionKey]: optionValue,
|
[optionKey]: optionValue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
options._onLinkClick = function (url) {
|
options._onLinkClick = function (url) {
|
||||||
chrome.tabs.create({
|
browser.tabs.create({
|
||||||
'url': url,
|
'url': url,
|
||||||
'active': true
|
'active': true
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,12 +50,6 @@ popup._renderContents = function () {
|
||||||
.then(popup._determineStatusGoogleFonts)
|
.then(popup._determineStatusGoogleFonts)
|
||||||
.then(popup._determineResourceInjections)
|
.then(popup._determineResourceInjections)
|
||||||
.then(popup._renderContextualContents);
|
.then(popup._renderContextualContents);
|
||||||
|
|
||||||
if (BrowserType.CHROMIUM) {
|
|
||||||
document.getElementById('div-manipulateDOM').hidden = true;
|
|
||||||
document.getElementById('div-google-fonts').hidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
popup._renderNonContextualContents = function () {
|
popup._renderNonContextualContents = function () {
|
||||||
|
@ -180,7 +174,7 @@ popup._enableProtection = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -191,7 +185,7 @@ popup._disableProtection = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -202,7 +196,7 @@ popup._enableManipulateDOM = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -213,7 +207,7 @@ popup._disableManipulateDOM = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -224,7 +218,7 @@ popup._enableGoogleFonts = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -235,7 +229,7 @@ popup._disableGoogleFonts = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function () {
|
browser.runtime.sendMessage(message, function () {
|
||||||
popup._onToggled();
|
popup._onToggled();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -251,7 +245,7 @@ popup._determineDomainAllowlistStatus = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (response) {
|
browser.runtime.sendMessage(message, function (response) {
|
||||||
popup._domainIsAllowlisted = response.value;
|
popup._domainIsAllowlisted = response.value;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -265,7 +259,7 @@ popup._determineStatusManipulateDOM = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (response) {
|
browser.runtime.sendMessage(message, function (response) {
|
||||||
popup._domainManipulateDOM = response.value;
|
popup._domainManipulateDOM = response.value;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -279,7 +273,7 @@ popup._determineStatusGoogleFonts = function () {
|
||||||
'value': popup._domain,
|
'value': popup._domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (response) {
|
browser.runtime.sendMessage(message, function (response) {
|
||||||
popup._domainGoogleFonts = response.value;
|
popup._domainGoogleFonts = response.value;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -293,7 +287,7 @@ popup._determineResourceInjections = function () {
|
||||||
'value': popup._targetTab.id,
|
'value': popup._targetTab.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (response) {
|
browser.runtime.sendMessage(message, function (response) {
|
||||||
let groupedInjections = popup._groupResourceInjections(response.value);
|
let groupedInjections = popup._groupResourceInjections(response.value);
|
||||||
popup._resourceInjections = groupedInjections;
|
popup._resourceInjections = groupedInjections;
|
||||||
|
|
||||||
|
@ -318,7 +312,7 @@ popup._getData = function () {
|
||||||
'topic': 'popup:get-data'
|
'topic': 'popup:get-data'
|
||||||
};
|
};
|
||||||
|
|
||||||
chrome.runtime.sendMessage(message, function (items) {
|
browser.runtime.sendMessage(message, function (items) {
|
||||||
popup._amountInjected = items.data.amountInjected;
|
popup._amountInjected = items.data.amountInjected;
|
||||||
popup._statisticsStatus = items.data.internalStatistics;
|
popup._statisticsStatus = items.data.internalStatistics;
|
||||||
popup.negateHtmlFilterList = items.data.negateHtmlFilterList;
|
popup.negateHtmlFilterList = items.data.negateHtmlFilterList;
|
||||||
|
@ -481,7 +475,7 @@ popup._filterDuplicates = function (array, key) {
|
||||||
popup._onDocumentLoaded = function () {
|
popup._onDocumentLoaded = function () {
|
||||||
let manifest, language;
|
let manifest, language;
|
||||||
|
|
||||||
manifest = chrome.runtime.getManifest();
|
manifest = browser.runtime.getManifest();
|
||||||
language = navigator.language;
|
language = navigator.language;
|
||||||
|
|
||||||
popup._name = manifest.name;
|
popup._name = manifest.name;
|
||||||
|
@ -495,7 +489,7 @@ popup._onButtonClick = function (ev) {
|
||||||
let dataLink = popupLinkList[ev.target.getAttribute('data-link')];
|
let dataLink = popupLinkList[ev.target.getAttribute('data-link')];
|
||||||
if (dataLink) {
|
if (dataLink) {
|
||||||
if (ev.button === 0 || ev.button === 1) {
|
if (ev.button === 0 || ev.button === 1) {
|
||||||
chrome.tabs.create({
|
browser.tabs.create({
|
||||||
'url': dataLink,
|
'url': dataLink,
|
||||||
'active': ev.button === 0,
|
'active': ev.button === 0,
|
||||||
});
|
});
|
||||||
|
@ -508,25 +502,25 @@ popup._onButtonClick = function (ev) {
|
||||||
};
|
};
|
||||||
|
|
||||||
popup._onOptionsButtonClicked = function () {
|
popup._onOptionsButtonClicked = function () {
|
||||||
chrome.runtime.openOptionsPage();
|
browser.runtime.openOptionsPage();
|
||||||
return window.close();
|
return window.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
popup._onToggled = function () {
|
popup._onToggled = function () {
|
||||||
let bypassCache = typeof browser === 'undefined';
|
let bypassCache = typeof browser === 'undefined';
|
||||||
|
|
||||||
chrome.tabs.reload(popup._targetTab.id, {bypassCache});
|
browser.tabs.reload(popup._targetTab.id, {bypassCache});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
popup._close();
|
popup._close();
|
||||||
}, 200);
|
}, 200);
|
||||||
};
|
};
|
||||||
|
|
||||||
popup._close = function () {
|
popup._close = function () {
|
||||||
chrome.runtime.getPlatformInfo(function (information) {
|
browser.runtime.getPlatformInfo(function (information) {
|
||||||
if (information.os === chrome.runtime.PlatformOs.ANDROID) {
|
if (information.os === browser.runtime.PlatformOs.ANDROID) {
|
||||||
chrome.tabs.getCurrent(function (activeTab) {
|
browser.tabs.getCurrent(function (activeTab) {
|
||||||
if (activeTab) {
|
if (activeTab) {
|
||||||
chrome.tabs.remove(activeTab.id);
|
browser.tabs.remove(activeTab.id);
|
||||||
} else {
|
} else {
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ statistics._onDocumentLoaded = function () {
|
||||||
helpers.insertI18nContentIntoDocument(document);
|
helpers.insertI18nContentIntoDocument(document);
|
||||||
helpers.insertI18nTitlesIntoDocument(document);
|
helpers.insertI18nTitlesIntoDocument(document);
|
||||||
|
|
||||||
chrome.storage.local.get([Setting.DEFAULT_RANGE_STATISTIC], function (items) {
|
browser.storage.local.get([Setting.DEFAULT_RANGE_STATISTIC], function (items) {
|
||||||
statistics._dateUnit = items.defaultRangeStatistic || 'week';
|
statistics._dateUnit = items.defaultRangeStatistic || 'week';
|
||||||
document.getElementById('date-range').value = statistics._dateUnit;
|
document.getElementById('date-range').value = statistics._dateUnit;
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ statistics._determineInjections = function () {
|
||||||
|
|
||||||
statistics._getStatistics = function () {
|
statistics._getStatistics = function () {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
chrome.storage.local.get([Setting.INTERNAL_STATISTICS_DATA], function (items) {
|
browser.storage.local.get([Setting.INTERNAL_STATISTICS_DATA], function (items) {
|
||||||
statistics._data = items.internalStatisticsData;
|
statistics._data = items.internalStatisticsData;
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
@ -248,17 +248,17 @@ statistics._handlerDateRange = function ({target}) {
|
||||||
};
|
};
|
||||||
|
|
||||||
statistics._deleteStatistic = function () {
|
statistics._deleteStatistic = function () {
|
||||||
let text = chrome.i18n.getMessage('dialogConfirmDeleteStatistics');
|
let text = browser.i18n.getMessage('dialogConfirmDeleteStatistics');
|
||||||
if (confirm(text)) {
|
if (confirm(text)) {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.INTERNAL_STATISTICS_DATA]: {}
|
[Setting.INTERNAL_STATISTICS_DATA]: {}
|
||||||
});
|
});
|
||||||
chrome.runtime.sendMessage({'topic': 'statistic:delete'});
|
browser.runtime.sendMessage({'topic': 'statistic:delete'});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
statistics._saveDefaultRange = function (value) {
|
statistics._saveDefaultRange = function (value) {
|
||||||
chrome.storage.local.set({
|
browser.storage.local.set({
|
||||||
[Setting.DEFAULT_RANGE_STATISTIC]: value
|
[Setting.DEFAULT_RANGE_STATISTIC]: value
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,10 +31,7 @@ welcome._onDocumentLoaded = function () {
|
||||||
helpers.insertI18nContentIntoDocument(document);
|
helpers.insertI18nContentIntoDocument(document);
|
||||||
helpers.insertI18nTitlesIntoDocument(document);
|
helpers.insertI18nTitlesIntoDocument(document);
|
||||||
|
|
||||||
if (!BrowserType.FIREFOX) {
|
document.getElementById('open-settings').addEventListener('mouseup', function () { browser.runtime.openOptionsPage(); });
|
||||||
document.getElementById('chromium-banner').style.display = 'block';
|
|
||||||
}
|
|
||||||
document.getElementById('open-settings').addEventListener('mouseup', function () { chrome.runtime.openOptionsPage(); });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', welcome._onDocumentLoaded);
|
document.addEventListener('DOMContentLoaded', welcome._onDocumentLoaded);
|
||||||
|
|
Loading…
Reference in New Issue