Skip to content

Commit

Permalink
Option to ignore preference pages to set language when ignoring search (
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelienlux committed Oct 30, 2020
1 parent 9e2e2b0 commit 83be463
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
22 changes: 20 additions & 2 deletions background.js
Expand Up @@ -237,7 +237,7 @@ function reopenTab ({url, tab, cookieStoreId}) {
index: tab.index + 1,
windowId: tab.windowId
});
// We do not want to erase google container if going from
// We do not want to erase google container if going from
// google container back to default.
if (!(isSearchPageURL(tab.url))) {
browser.tabs.remove(tab.id);
Expand Down Expand Up @@ -269,6 +269,16 @@ function isSearchPageURL (url) {
return parsedUrl.pathname.startsWith('/search');
}

function isPrefPageURL (url) {
const parsedUrl = new URL(url);
return parsedUrl.pathname.startsWith('/preferences');
}

function isSetprefsPageURL (url) {
const parsedUrl = new URL(url);
return parsedUrl.pathname.startsWith('/setprefs');
}

function isMapsURL (url) {
const parsedUrl = new URL(url);
return parsedUrl.pathname.startsWith('/maps');
Expand All @@ -295,6 +305,14 @@ function shouldContainInto (url, tab) {
handleUrl = false;
}

if (handleUrl && extensionSettings.ignore_prefpages && isPrefPageURL(url)) {
handleUrl = false;
}

if (handleUrl && extensionSettings.ignore_prefpages && isSetprefsPageURL(url)) {
handleUrl = false;
}

if (handleUrl && extensionSettings.ignore_maps && isMapsURL(url)) {
handleUrl = false;
}
Expand All @@ -309,7 +327,7 @@ function shouldContainInto (url, tab) {
// Tab is already in a container, the user doesn't want us to override containers
return false;
}

// Google-URL outside of Google Container Tab
// Should contain into Google Container
return googleCookieStoreId;
Expand Down
10 changes: 9 additions & 1 deletion options.html
Expand Up @@ -30,6 +30,14 @@ <h1>Settings</h1>
</label>
</p>

<p>
<label>
<input type="checkbox" id="ignore_prefpages" value="1">
Ignore preference pages<br>
<em>(Means don't use Google Container on Google sites with a path of <code>/preferences</code> and <code>/setprefs</code>. Useful when ignoring search pages to still be able to change search language.)</em>
</label>
</p>

<p>
<label>
<input type="checkbox" id="ignore_maps" value="1">
Expand All @@ -45,7 +53,7 @@ <h1>Settings</h1>
<em>(Means don't use Google Container on Google sites with a path of <code>/flights</code>.)</em>
</label>
</p>

<p>
<label>
<input type="checkbox" id="dont_override_containers" value="1">
Expand Down
2 changes: 2 additions & 0 deletions options.js
Expand Up @@ -6,6 +6,7 @@ function onOptionsPageSave(e)
browser.storage.sync.set({
"ignore_youtube": document.querySelector("#ignore_youtube").checked,
"ignore_searchpages": document.querySelector("#ignore_searchpages").checked,
"ignore_prefpages": document.querySelector("#ignore_prefpages").checked,
"ignore_maps": document.querySelector("#ignore_maps").checked,
"ignore_flights": document.querySelector("#ignore_flights").checked,
"dont_override_containers": document.querySelector("#dont_override_containers").checked
Expand All @@ -22,6 +23,7 @@ function onOptionsPageLoaded()
{
document.querySelector("#ignore_youtube").checked = res.ignore_youtube || false;
document.querySelector("#ignore_searchpages").checked = res.ignore_searchpages || false;
document.querySelector("#ignore_prefpages").checked = res.ignore_prefpages || false;
document.querySelector("#ignore_maps").checked = res.ignore_maps || false;
document.querySelector("#ignore_flights").checked = res.ignore_flights || false;
document.querySelector("#dont_override_containers").checked = res.override_containers || false;
Expand Down

0 comments on commit 83be463

Please sign in to comment.