diff --git a/core/main.js b/core/main.js index 0b83382c..874f47ba 100644 --- a/core/main.js +++ b/core/main.js @@ -150,9 +150,19 @@ main._showReleaseNotes = function (details) { } }; +main._permissionStatusListener = function (e) { + if (e.permissions.includes('')) { + chrome.tabs.create({ + 'url': chrome.runtime.getURL('pages/info/info.html'), + 'active': true + }); + } +}; + /** * Initializations */ chrome.runtime.onInstalled.addListener(main._showReleaseNotes); +browser.permissions.onRemoved.addListener(main._permissionStatusListener); main._initializeSettings(); diff --git a/core/messenger.js b/core/messenger.js index 969bf217..1e6487c0 100644 --- a/core/messenger.js +++ b/core/messenger.js @@ -45,7 +45,7 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) { return MessageResponse.SYNCHRONOUS; case 'tab:inject': - chrome.tabs.executeScript(value, { + chrome.scripting.executeScript(value, { 'code': `window.addEventListener('load', () => { document.getElementById('domain').value = '${message.url}'; });`, diff --git a/core/state-manager.js b/core/state-manager.js index e52f4f22..1f376e10 100644 --- a/core/state-manager.js +++ b/core/state-manager.js @@ -46,7 +46,7 @@ stateManager.registerInjection = function (tabIdentifier, injection, url) { missingCount = registeredTab.missing || 0; if (injectionCount > 0) { - chrome.browserAction.setTitle({ + chrome.action.setTitle({ 'tabId': tabIdentifier, 'title': `LocalCDN (${injectionCount})` }); @@ -185,14 +185,14 @@ stateManager._updateTab = function (details) { return; } - chrome.browserAction.setTitle({ + chrome.action.setTitle({ 'tabId': tabIdentifier, 'title': 'LocalCDN (0)' }); if (domainIsAllowlisted) { stateManager._setIconDisabled(tabIdentifier); - chrome.browserAction.setTitle({ + chrome.action.setTitle({ 'tabId': tabIdentifier, 'title': 'LocalCDN (–)' }); diff --git a/manifest.json b/manifest.json index 0b363431..76e3ecb0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,11 @@ { - "manifest_version": 2, - "name": "LocalCDN", - "version": "2.6.44", + "manifest_version": 3, + "name": "LocalCDN Beta", + "version": "3.0.0", "browser_specific_settings": { "gecko": { "id": "{b86e4813-687a-43e6-ab65-0bde4ab75758}", - "strict_min_version": "86.0" + "strict_min_version": "101.0" } }, "author": "nobody", @@ -21,19 +21,19 @@ }, "permissions": [ - "*://*/*", "privacy", "storage", "webNavigation", "webRequest", - "webRequestBlocking" + "webRequestBlocking", + "scripting" ], - "background": { - "page": "pages/background/background.html" - }, + "host_permissions": [ + "" + ], - "browser_action": { + "action": { "default_icon": { "16": "icons/action/default/icon16-default.png", "18": "icons/action/default/icon18-default.png", @@ -47,16 +47,40 @@ "browser_style": false }, + "background": { + "scripts": [ + "core/constants.js", + "core/storage-manager.js", + + "modules/internal/wrappers.js", + "modules/internal/targets.js", + "modules/internal/helpers.js", + "modules/internal/stats.js", + "modules/internal/log.js", + + "core/resources.js", + "core/mappings.js", + "core/shorthands.js", + "core/request-sanitizer.js", + "core/state-manager.js", + "core/request-analyzer.js", + "core/file-guard.js", + "core/messenger.js", + "core/interceptor.js", + "core/manipulate-dom.js", + "core/main.js" + ] + }, + "options_ui": { "page": "pages/options/options.html", "open_in_tab": true }, - "web_accessible_resources": [ - "resources/*" - ], - - "content_security_policy": "default-src 'self'; img-src 'self' data:", + "web_accessible_resources": [{ + "resources": ["resources/*"], + "matches": [""] + }], "commands": { "_execute_browser_action": {} } diff --git a/pages/info/host_permissions.png b/pages/info/host_permissions.png new file mode 100644 index 00000000..15e572db Binary files /dev/null and b/pages/info/host_permissions.png differ diff --git a/pages/info/info.css b/pages/info/info.css new file mode 100644 index 00000000..5c701e22 --- /dev/null +++ b/pages/info/info.css @@ -0,0 +1,3 @@ +img { + width: 100% +} diff --git a/pages/info/info.html b/pages/info/info.html new file mode 100644 index 00000000..f1b6cc8e --- /dev/null +++ b/pages/info/info.html @@ -0,0 +1,25 @@ + + + + Information | LocalCDN + + + + + + + + + + +

Permission revoked

+
+

Access your data for all websites

+

Please do not disable the permission. LocalCDN needs the permission to detect and redirect requests to CDNs.

+ +
+ + + diff --git a/pages/info/info.js b/pages/info/info.js new file mode 100644 index 00000000..f6061f90 --- /dev/null +++ b/pages/info/info.js @@ -0,0 +1,47 @@ +/** + * Info Page + * Belongs to LocalCDN (since 2020-02-26) + * + * @author nobody + * @since 2022-12-28 + * + * @license MPL 2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +'use strict'; + + +/** + * Help + */ + +var info = {}; + + +/** + * Private Methods + */ + +info._onDocumentLoaded = function () { + let language = navigator.language; + + info._languageSupported = helpers.languageIsFullySupported(language); + info._scriptDirection = helpers.determineScriptDirection(language); + + if (!helpers.insertI18nContentIntoDocument(document)) { + document.getElementById('notice-locale').style.display = 'block'; + } + + chrome.permissions.request({'origins': ['']}); +}; + + +/** + * Initializations + */ + +document.addEventListener('DOMContentLoaded', info._onDocumentLoaded);