URL exception list for remove querystrings feature
This commit is contained in:
parent
98decf9a49
commit
af507b10b4
@ -4,12 +4,13 @@ function onError(error) {
|
|||||||
|
|
||||||
function shareURL(selectionContent,currentTab){
|
function shareURL(selectionContent,currentTab){
|
||||||
|
|
||||||
browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings"],function(item){
|
browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings","exceptUrlList"],function(item){
|
||||||
|
|
||||||
instance = item["instance_url"];
|
instance = item["instance_url"];
|
||||||
windowWidth = item["window_width"];
|
windowWidth = item["window_width"];
|
||||||
windowHeight = item["window_height"];
|
windowHeight = item["window_height"];
|
||||||
noQueryStrings = item["remove_querystrings"];
|
noQueryStrings = item["remove_querystrings"];
|
||||||
|
exceptUrlList = item["exceptUrlList"];
|
||||||
|
|
||||||
// manages Mozilla Firefox reader mode
|
// manages Mozilla Firefox reader mode
|
||||||
var rawUrl = currentTab.url;
|
var rawUrl = currentTab.url;
|
||||||
@ -21,7 +22,14 @@ function shareURL(selectionContent,currentTab){
|
|||||||
|
|
||||||
// manages URL query strings
|
// manages URL query strings
|
||||||
if (noQueryStrings == true) {
|
if (noQueryStrings == true) {
|
||||||
rawUrl = rawUrl.split("?")[0];
|
var flagRemove = true;
|
||||||
|
var urlList = exceptUrlList.split(/,\s*/);
|
||||||
|
urlList.forEach(function(baseUrl) {
|
||||||
|
if (rawUrl.startsWith(baseUrl)) {
|
||||||
|
flagRemove = false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (flagRemove) {rawUrl = rawUrl.split("?")[0];}
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(rawUrl) + "&title=" + encodeURIComponent(currentTab.title) + "&description=" + encodeURIComponent(selectionContent);
|
var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(rawUrl) + "&title=" + encodeURIComponent(currentTab.title) + "&description=" + encodeURIComponent(selectionContent);
|
||||||
|
@ -39,9 +39,9 @@
|
|||||||
"commands": {
|
"commands": {
|
||||||
"_execute_browser_action": {
|
"_execute_browser_action": {
|
||||||
"suggested_key": {
|
"suggested_key": {
|
||||||
"default": "Alt+Shift+S"
|
"default": "Alt+Shift+S"
|
||||||
},
|
},
|
||||||
"description": "dd to (Semantic)Scuttle keyboard shortcut"
|
"description": "Add to (Semantic)Scuttle keyboard shortcut"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<label>(Semantic)Scuttle instance URL <input type="text" id="instance_url" ></label><br />
|
<label>(Semantic)Scuttle instance URL <input type="text" id="instance_url" ></label><br />
|
||||||
<label>Window Width <input type="text" id="window_width" ></label><br />
|
<label>Window Width <input type="text" id="window_width" ></label><br />
|
||||||
<label>Window Height <input type="text" id="window_height" ></label><br />
|
<label>Window Height <input type="text" id="window_height" ></label><br />
|
||||||
<label>Remove querystrings from URL<input type="checkbox" id="remove_querystrings" ></label><br />
|
<label>Remove querystrings from URL <input type="checkbox" id="remove_querystrings" ></label><label> Except for (separated by commas) <input type="text" id="exceptUrlList"></label><br />
|
||||||
<button type="submit">Save</button>
|
<button type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ function saveOptions(e) {
|
|||||||
instance_url: document.querySelector("#instance_url").value ,
|
instance_url: document.querySelector("#instance_url").value ,
|
||||||
window_width: document.querySelector("#window_width").value ,
|
window_width: document.querySelector("#window_width").value ,
|
||||||
window_height: document.querySelector("#window_height").value,
|
window_height: document.querySelector("#window_height").value,
|
||||||
remove_querystrings: document.querySelector("#remove_querystrings").checked
|
remove_querystrings: document.querySelector("#remove_querystrings").checked,
|
||||||
|
exceptUrlList: document.querySelector("#exceptUrlList").value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,13 +16,14 @@ function restoreOptions() {
|
|||||||
document.querySelector("#window_width").value = result["window_width"] || "640";
|
document.querySelector("#window_width").value = result["window_width"] || "640";
|
||||||
document.querySelector("#window_height").value = result["window_height"] || "480";
|
document.querySelector("#window_height").value = result["window_height"] || "480";
|
||||||
document.querySelector("#remove_querystrings").checked = result["remove_querystrings"] || false;
|
document.querySelector("#remove_querystrings").checked = result["remove_querystrings"] || false;
|
||||||
|
document.querySelector("#exceptUrlList").value = result["exceptUrlList"] || "https://www.google.fr,https://www.youtube.com,http://lalist.inist.fr,https://www.qwant.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
console.log(`Error: ${error}`);
|
console.log(`Error: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
var getting = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings"]);
|
var getting = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings","exceptUrlList"]);
|
||||||
getting.then(setCurrentChoices, onError);
|
getting.then(setCurrentChoices, onError);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user