I have the following script trigger from a browser extension with the idea that it will edit the URL and load the page with the new URL. This works as expected until a certain point.
$('#Change_btn').click(function() {
chrome.tabs.query({active:true},tabs=>{
url=tabs[0].url.replace("en-US","nb-NO")
chrome.tabs.update({url})
})
});
I discovered that if I have multiple Chrome windows open, the script will chose a random active tab, and load this in the tab I have open in the window I trigger the script from.
Is it possible to specify / isolate this script to the actual window where the script is triggered? If so, how would I do this?
Solved
Added currentWindow: true
to chrome.tabs.query({active:true},tabs=>{
making the finished script look like this:
$('#Change_btn').click(function() {
chrome.tabs.query({active:true, currentWindow: true},tabs=>{
url=tabs[0].url.replace("en-US","nb-NO")
chrome.tabs.update({url})
})
});
currentWindow: true
– wOxxOm