Improved: "Website broken?" Link in popup menu (#278)

This commit is contained in:
nobody 2021-02-21 19:40:52 +01:00
parent c59006ae95
commit fada320de2
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 24 additions and 2 deletions

View File

@ -214,7 +214,7 @@ const Links = {
'FAQ_HTML_FILTER': chrome.extension.getURL('pages/help/help.html#html-filter'),
'STATISTICS': chrome.extension.getURL('pages/statistics/statistics.html'),
'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/',
};

View File

@ -97,6 +97,16 @@ messenger._handleMessageReceived = function (message, sender, sendResponse) {
if (topic === 'deleteStatistic') {
storageManager.statistics = {};
}
if (topic === 'injection') {
chrome.tabs.executeScript(value, {
'code': `window.addEventListener('load', () => {
document.getElementById('domain').value = '${message.url}';
});`,
'runAt': 'document_start'
});
}
};

View File

@ -439,8 +439,10 @@ popup._onDocumentLoaded = function () {
popup._onTestingUtilityLinkClicked = function (event) {
if (event.button === 0 || event.button === 1) {
chrome.tabs.create({
'url': Links.LOCALCDN_TEST_WEBSITE + popup._targetTab.url,
'url': Links.LOCALCDN_TEST_WEBSITE,
'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 () {
chrome.runtime.openOptionsPage();
return window.close();