Option to remove query strings from URL
This commit is contained in:
parent
b127e1e9f9
commit
5edda2b0d6
1
TODO
1
TODO
@ -1,3 +1,2 @@
|
|||||||
-Option to clean URLs (after the ?)
|
|
||||||
-Add keyboard shortcut if possible
|
-Add keyboard shortcut if possible
|
||||||
-Bug corrections & optimizations
|
-Bug corrections & optimizations
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
var instance
|
var instance
|
||||||
var windowWidth
|
var windowWidth
|
||||||
var windowHeight
|
var windowHeight
|
||||||
|
var noQueryStrings
|
||||||
|
|
||||||
// prefs are not loaded once before shareURL it won't work on first click.
|
// prefs are not loaded once before shareURL it won't work on first click.
|
||||||
var gettingPrefs = browser.storage.local.get(["instance_url","window_width","window_height"]);
|
var gettingPrefs = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings"]);
|
||||||
gettingPrefs.then(onGot,onError);
|
gettingPrefs.then(onGot,onError);
|
||||||
|
|
||||||
function shareURL(){
|
function shareURL(){
|
||||||
browser.tabs.query({active: true},function(tabs){
|
browser.tabs.query({active: true},function(tabs){
|
||||||
|
|
||||||
// prefs are loaded again when the function is called to manage changes in the options page.
|
// prefs are loaded again when the function is called to manage changes in the options page.
|
||||||
let gettingPrefs = browser.storage.local.get(["instance_url","window_width","window_height"]);
|
let gettingPrefs = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings"]);
|
||||||
gettingPrefs.then(onGot,onError);
|
gettingPrefs.then(onGot,onError);
|
||||||
|
|
||||||
var tab = tabs[0];
|
var tab = tabs[0];
|
||||||
@ -23,6 +24,11 @@ function shareURL(){
|
|||||||
rawUrl = decodeURIComponent(rawUrl);
|
rawUrl = decodeURIComponent(rawUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manages URL query strings
|
||||||
|
if (noQueryStrings == true) {
|
||||||
|
rawUrl = rawUrl.split("?")[0];
|
||||||
|
}
|
||||||
|
|
||||||
var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(rawUrl) + "&title=" + encodeURIComponent(tabs[0].title);
|
var url = instance + "/bookmarks.php?action=add&address=" + encodeURIComponent(rawUrl) + "&title=" + encodeURIComponent(tabs[0].title);
|
||||||
widthInt = Number(windowWidth);
|
widthInt = Number(windowWidth);
|
||||||
heightInt = Number(windowHeight);
|
heightInt = Number(windowHeight);
|
||||||
@ -56,6 +62,7 @@ function onGot(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"];
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"manifest_version" : 2,
|
"manifest_version" : 2,
|
||||||
"name": "Add to (Semantic)Scuttle",
|
"name": "Add to (Semantic)Scuttle",
|
||||||
"version" : "0.5",
|
"version" : "0.6",
|
||||||
"description" : "Add bookmarks to a (Semantic)Scuttle instance, a social bookmarking tool experimenting with tags and collaborative tag descriptions.",
|
"description" : "Add bookmarks to a (Semantic)Scuttle instance, a social bookmarking tool experimenting with tags and collaborative tag descriptions.",
|
||||||
"homepage_url" : "https://github.com/FrenchHope/Add-to-Semantic-Scuttle-WebExt",
|
"homepage_url" : "https://addons.mozilla.org/fr/firefox/addon/add-to-semantic-scuttle/",
|
||||||
"icons" : {
|
"icons" : {
|
||||||
"48" : "data/icon48.png"
|
"48" : "data/icon48.png"
|
||||||
},
|
},
|
||||||
|
@ -11,6 +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 />
|
||||||
<button type="submit">Save</button>
|
<button type="submit">Save</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@ function saveOptions(e) {
|
|||||||
browser.storage.local.set({
|
browser.storage.local.set({
|
||||||
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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,13 +14,14 @@ function restoreOptions() {
|
|||||||
document.querySelector("#instance_url").value = result["instance_url"] || "http://semanticscuttle.sourceforge.net/";
|
document.querySelector("#instance_url").value = result["instance_url"] || "http://semanticscuttle.sourceforge.net/";
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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"]);
|
var getting = browser.storage.local.get(["instance_url","window_width","window_height","remove_querystrings"]);
|
||||||
getting.then(setCurrentChoices, onError);
|
getting.then(setCurrentChoices, onError);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user