mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-02-17 20:30:57 +01:00
Improved: "Website broken?" Link in popup menu (#278)
This commit is contained in:
parent
c59006ae95
commit
fada320de2
@ -214,7 +214,7 @@ const Links = {
|
|||||||
'FAQ_HTML_FILTER': chrome.extension.getURL('pages/help/help.html#html-filter'),
|
'FAQ_HTML_FILTER': chrome.extension.getURL('pages/help/help.html#html-filter'),
|
||||||
'STATISTICS': chrome.extension.getURL('pages/statistics/statistics.html'),
|
'STATISTICS': chrome.extension.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?domain=',
|
'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/',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,6 +97,16 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
|
|||||||
if (topic === 'deleteStatistic') {
|
if (topic === 'deleteStatistic') {
|
||||||
storageManager.statistics = {};
|
storageManager.statistics = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (topic === 'injection') {
|
||||||
|
|
||||||
|
chrome.tabs.executeScript(value, {
|
||||||
|
'code': `window.addEventListener('load', () => {
|
||||||
|
document.getElementById('domain').value = '${message.url}';
|
||||||
|
});`,
|
||||||
|
'runAt': 'document_start'
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,8 +439,10 @@ popup._onDocumentLoaded = function () {
|
|||||||
popup._onTestingUtilityLinkClicked = function (event) {
|
popup._onTestingUtilityLinkClicked = function (event) {
|
||||||
if (event.button === 0 || event.button === 1) {
|
if (event.button === 0 || event.button === 1) {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
'url': Links.LOCALCDN_TEST_WEBSITE + popup._targetTab.url,
|
'url': Links.LOCALCDN_TEST_WEBSITE,
|
||||||
'active': event.button === 0,
|
'active': event.button === 0,
|
||||||
|
}, function (tab) {
|
||||||
|
popup._injectDomain(tab.id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,6 +451,16 @@ popup._onTestingUtilityLinkClicked = function (event) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
popup._injectDomain = function (tabId) {
|
||||||
|
let message = {
|
||||||
|
'topic': 'injection',
|
||||||
|
'value': tabId,
|
||||||
|
'url': popup._targetTab.url
|
||||||
|
};
|
||||||
|
|
||||||
|
chrome.runtime.sendMessage(message);
|
||||||
|
};
|
||||||
|
|
||||||
popup._onOptionsButtonClicked = function () {
|
popup._onOptionsButtonClicked = function () {
|
||||||
chrome.runtime.openOptionsPage();
|
chrome.runtime.openOptionsPage();
|
||||||
return window.close();
|
return window.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user