Preserved url's path. Only the domain will change now.
This commit is contained in:
parent
398b122ec6
commit
97d3d19b7d
|
@ -15,6 +15,7 @@
|
|||
"128": "assets/images/icon128.png"
|
||||
},
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"storage",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
|
|
|
@ -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);
|
Loading…
Reference in New Issue