supporting custom ua string per container
This commit is contained in:
parent
bf16cb694a
commit
2a317e5aec
5 changed files with 112 additions and 67 deletions
|
@ -190,6 +190,7 @@ select {
|
|||
background-color: #4d72b7;
|
||||
color: #fff;
|
||||
}
|
||||
[data-cmd="container"],
|
||||
[data-cmd="window"],
|
||||
[data-cmd="apply"] {
|
||||
color: #fff;
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
<input type="button" value="Refresh Tab" title="Refresh the current page" data-cmd="refresh">
|
||||
<input type="button" value="Reset" title="Reset User-Agent string to the default one. This will not reset window-based UA strings. To reset them, use the 'Restart' button" data-cmd="reset">
|
||||
<input type="button" value="Test" title="Test your user-agent string" data-cmd="test">
|
||||
<span></span>
|
||||
<input type="button" value="Container" title="Set this string as this container's User-Agent string" data-cmd="container">
|
||||
<input type="button" value="Window" title="Set this string as this window's User-Agent string" data-cmd="window">
|
||||
<input type="button" value="Apply" title="Set this string as the browser's User-Agent string" data-cmd="apply">
|
||||
</div>
|
||||
|
|
|
@ -237,12 +237,27 @@ document.addEventListener('click', ({target}) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
else if (cmd === 'window') {
|
||||
else if (cmd === 'window' || cmd === 'container') {
|
||||
const value = document.getElementById('ua').value;
|
||||
chrome.tabs.query({
|
||||
const next = () => chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, ([tab]) => chrome.runtime.getBackgroundPage(bg => bg.ua.update(value, tab.windowId)));
|
||||
}, ([tab]) => {
|
||||
if (cmd === 'window') {
|
||||
chrome.runtime.getBackgroundPage(bg => bg.ua.update(value, tab.windowId, tab.cookieStoreId));
|
||||
}
|
||||
else {
|
||||
chrome.runtime.getBackgroundPage(bg => bg.ua.update(value, undefined, tab.cookieStoreId));
|
||||
}
|
||||
});
|
||||
if (cmd === 'container') {
|
||||
chrome.permissions.request({
|
||||
permissions: ['cookies']
|
||||
}, granted => granted && next());
|
||||
}
|
||||
else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
else if (cmd === 'reset') {
|
||||
const input = document.querySelector('#list :checked');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue