diff --git a/background.js b/background.js index 7694c92..87dfa3e 100644 --- a/background.js +++ b/background.js @@ -4,12 +4,13 @@ function onError(error) { 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"]; windowWidth = item["window_width"]; windowHeight = item["window_height"]; noQueryStrings = item["remove_querystrings"]; + exceptUrlList = item["exceptUrlList"]; // manages Mozilla Firefox reader mode var rawUrl = currentTab.url; @@ -21,7 +22,14 @@ function shareURL(selectionContent,currentTab){ // manages URL query strings 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); diff --git a/manifest.json b/manifest.json index 9c11bcb..2ca8a0b 100644 --- a/manifest.json +++ b/manifest.json @@ -39,9 +39,9 @@ "commands": { "_execute_browser_action": { "suggested_key": { - "default": "Alt+Shift+S" + "default": "Alt+Shift+S" }, - "description": "dd to (Semantic)Scuttle keyboard shortcut" + "description": "Add to (Semantic)Scuttle keyboard shortcut" } } } diff --git a/options.html b/options.html index 3cde084..06ca612 100644 --- a/options.html +++ b/options.html @@ -11,7 +11,7 @@


-
+
diff --git a/options.js b/options.js index 31f71a2..b35c1a8 100644 --- a/options.js +++ b/options.js @@ -4,7 +4,8 @@ function saveOptions(e) { instance_url: document.querySelector("#instance_url").value , window_width: document.querySelector("#window_width").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_height").value = result["window_height"] || "480"; 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) { 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); }