mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-06-05 21:49:31 +02:00
mv3 init (#1274)
This commit is contained in:
10
core/main.js
10
core/main.js
@@ -150,9 +150,19 @@ main._showReleaseNotes = function (details) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
main._permissionStatusListener = function (e) {
|
||||||
|
if (e.permissions.includes('<all_urls>')) {
|
||||||
|
chrome.tabs.create({
|
||||||
|
'url': chrome.runtime.getURL('pages/info/info.html'),
|
||||||
|
'active': true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializations
|
* Initializations
|
||||||
*/
|
*/
|
||||||
chrome.runtime.onInstalled.addListener(main._showReleaseNotes);
|
chrome.runtime.onInstalled.addListener(main._showReleaseNotes);
|
||||||
|
browser.permissions.onRemoved.addListener(main._permissionStatusListener);
|
||||||
main._initializeSettings();
|
main._initializeSettings();
|
||||||
|
@@ -45,7 +45,7 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
|||||||
return MessageResponse.SYNCHRONOUS;
|
return MessageResponse.SYNCHRONOUS;
|
||||||
|
|
||||||
case 'tab:inject':
|
case 'tab:inject':
|
||||||
chrome.tabs.executeScript(value, {
|
chrome.scripting.executeScript(value, {
|
||||||
'code': `window.addEventListener('load', () => {
|
'code': `window.addEventListener('load', () => {
|
||||||
document.getElementById('domain').value = '${message.url}';
|
document.getElementById('domain').value = '${message.url}';
|
||||||
});`,
|
});`,
|
||||||
|
@@ -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.browserAction.setTitle({
|
chrome.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': `LocalCDN (${injectionCount})`
|
'title': `LocalCDN (${injectionCount})`
|
||||||
});
|
});
|
||||||
@@ -185,14 +185,14 @@ stateManager._updateTab = function (details) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.browserAction.setTitle({
|
chrome.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': 'LocalCDN (0)'
|
'title': 'LocalCDN (0)'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (domainIsAllowlisted) {
|
if (domainIsAllowlisted) {
|
||||||
stateManager._setIconDisabled(tabIdentifier);
|
stateManager._setIconDisabled(tabIdentifier);
|
||||||
chrome.browserAction.setTitle({
|
chrome.action.setTitle({
|
||||||
'tabId': tabIdentifier,
|
'tabId': tabIdentifier,
|
||||||
'title': 'LocalCDN (–)'
|
'title': 'LocalCDN (–)'
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 3,
|
||||||
"name": "LocalCDN",
|
"name": "LocalCDN Beta",
|
||||||
"version": "2.6.44",
|
"version": "3.0.0",
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{b86e4813-687a-43e6-ab65-0bde4ab75758}",
|
"id": "{b86e4813-687a-43e6-ab65-0bde4ab75758}",
|
||||||
"strict_min_version": "86.0"
|
"strict_min_version": "101.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"author": "nobody",
|
"author": "nobody",
|
||||||
@@ -21,19 +21,19 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"*://*/*",
|
|
||||||
"privacy",
|
"privacy",
|
||||||
"storage",
|
"storage",
|
||||||
"webNavigation",
|
"webNavigation",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking"
|
"webRequestBlocking",
|
||||||
|
"scripting"
|
||||||
],
|
],
|
||||||
|
|
||||||
"background": {
|
"host_permissions": [
|
||||||
"page": "pages/background/background.html"
|
"<all_urls>"
|
||||||
},
|
],
|
||||||
|
|
||||||
"browser_action": {
|
"action": {
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"16": "icons/action/default/icon16-default.png",
|
"16": "icons/action/default/icon16-default.png",
|
||||||
"18": "icons/action/default/icon18-default.png",
|
"18": "icons/action/default/icon18-default.png",
|
||||||
@@ -47,16 +47,40 @@
|
|||||||
"browser_style": false
|
"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": {
|
"options_ui": {
|
||||||
"page": "pages/options/options.html",
|
"page": "pages/options/options.html",
|
||||||
"open_in_tab": true
|
"open_in_tab": true
|
||||||
},
|
},
|
||||||
|
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [{
|
||||||
"resources/*"
|
"resources": ["resources/*"],
|
||||||
],
|
"matches": ["<all_urls>"]
|
||||||
|
}],
|
||||||
"content_security_policy": "default-src 'self'; img-src 'self' data:",
|
|
||||||
|
|
||||||
"commands": { "_execute_browser_action": {} }
|
"commands": { "_execute_browser_action": {} }
|
||||||
|
|
||||||
|
BIN
pages/info/host_permissions.png
Normal file
BIN
pages/info/host_permissions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
3
pages/info/info.css
Normal file
3
pages/info/info.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
img {
|
||||||
|
width: 100%
|
||||||
|
}
|
25
pages/info/info.html
Normal file
25
pages/info/info.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Information | LocalCDN</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="icon" href="../images/favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../style.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../base.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="info.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img src="../images/logo.svg" alt="" class="logo">
|
||||||
|
<h1 data-i18n-content="permissionRevokedHeader">Permission revoked</h1>
|
||||||
|
<div class="notice">
|
||||||
|
<p data-i18n-content="permissionRevokedPermissionName">Access your data for all websites</p>
|
||||||
|
<p data-i18n-content="permissionRevokedDescription">Please do not disable the permission. LocalCDN needs the permission to detect and redirect requests to CDNs.</p>
|
||||||
|
<img src="host_permissions.png" alt="" class="img-host-permissions">
|
||||||
|
</div>
|
||||||
|
<div class="notice notice-default hidden" id="notice-locale">
|
||||||
|
<p>Your preferred language is not yet fully supported. Please help out by translating this add-on on <a class="button button-notice button-warning" href="https://hosted.weblate.org/projects/localcdn/localcdn/" target="_blank" rel="noopener noreferrer">Weblate</a>.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
47
pages/info/info.js
Normal file
47
pages/info/info.js
Normal file
@@ -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': ['<all_urls>']});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializations
|
||||||
|
*/
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', info._onDocumentLoaded);
|
Reference in New Issue
Block a user