Preserved url's path. Only the domain will change now.

This commit is contained in:
ManeraKai 2021-10-27 10:18:05 +03:00
parent 398b122ec6
commit 97d3d19b7d
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
2 changed files with 15 additions and 7 deletions

View File

@ -15,6 +15,7 @@
"128": "assets/images/icon128.png"
},
"permissions": [
"tabs",
"storage",
"webRequest",
"webRequestBlocking",

View File

@ -688,12 +688,19 @@ browser.runtime.onInstalled.addListener((details) => {
});
function openPage() {
function changeInstance() {
browser.tabs.query({
active: true,
lastFocusedWindow: true
}, function (tabs) {
var tabUrl = new URL(tabs[0].url);
if (oldDomain != '') {
browser.tabs.update({
url: oldDomain
url: tabUrl.href.replace(`${tabUrl.protocol}//${tabUrl.host}/`, oldDomain)
});
}
});
}
}
browser.pageAction.onClicked.addListener(openPage);
browser.pageAction.onClicked.addListener(changeInstance);