Merge branch 'develop' into main
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Added checkbox to enable/disable archiving to popup.
This commit is contained in:
commit
861232ab38
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "remwharead",
|
"name": "remwharead",
|
||||||
"version": "0.3.1",
|
"version": "0.4.0",
|
||||||
|
|
||||||
"description": "Integrates remwharead into your Browser.",
|
"description": "Integrates remwharead into your Browser.",
|
||||||
"homepage_url": "https://schlomp.space/tastytea/remwharead",
|
"homepage_url": "https://schlomp.space/tastytea/remwharead",
|
||||||
|
|
|
@ -9,7 +9,7 @@ function save_options(e)
|
||||||
|
|
||||||
function restore_options()
|
function restore_options()
|
||||||
{
|
{
|
||||||
var item = browser.storage.sync.get('archive');
|
const item = browser.storage.sync.get('archive');
|
||||||
item.then((res) =>
|
item.then((res) =>
|
||||||
{
|
{
|
||||||
if (res.archive === false)
|
if (res.archive === false)
|
||||||
|
@ -24,10 +24,10 @@ function info_commands(commands)
|
||||||
commands.forEach(
|
commands.forEach(
|
||||||
function(command)
|
function(command)
|
||||||
{
|
{
|
||||||
var element = document.querySelector("#shortcuts");
|
const element = document.querySelector("#shortcuts");
|
||||||
var para = document.createElement("p");
|
const para = document.createElement("p");
|
||||||
|
|
||||||
var text = document.createElement("strong");
|
const text = document.createElement("strong");
|
||||||
text.appendChild(document.createTextNode(command.shortcut + ": "));
|
text.appendChild(document.createTextNode(command.shortcut + ": "));
|
||||||
para.appendChild(text);
|
para.appendChild(text);
|
||||||
para.appendChild(document.createTextNode(command.description));
|
para.appendChild(document.createTextNode(command.description));
|
||||||
|
@ -39,5 +39,5 @@ function info_commands(commands)
|
||||||
document.addEventListener('DOMContentLoaded', restore_options);
|
document.addEventListener('DOMContentLoaded', restore_options);
|
||||||
document.querySelector("#archive").addEventListener("change", save_options);
|
document.querySelector("#archive").addEventListener("change", save_options);
|
||||||
|
|
||||||
var get_commands = browser.commands.getAll();
|
const get_commands = browser.commands.getAll();
|
||||||
get_commands.then(info_commands);
|
get_commands.then(info_commands);
|
||||||
|
|
|
@ -7,8 +7,14 @@
|
||||||
<!-- I did not use a form here because I want to display status and
|
<!-- I did not use a form here because I want to display status and
|
||||||
error messages inside the popup. -->
|
error messages inside the popup. -->
|
||||||
<label for="txttags">Tags, comma separated:</label>
|
<label for="txttags">Tags, comma separated:</label>
|
||||||
<input type="text" id="txttags" autofocus>
|
<input type="text" id="txttags" autofocus/>
|
||||||
<input type="button" id="btnadd" value="Add URI">
|
<div>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="chkarchive" value="archive" checked/>
|
||||||
|
Archive
|
||||||
|
</label>
|
||||||
|
<input type="button" id="btnadd" value="Add URI" style="float:right;"/>
|
||||||
|
</div>
|
||||||
<em id="msgstatus"></em>
|
<em id="msgstatus"></em>
|
||||||
<strong id="msgerror"></strong>
|
<strong id="msgerror"></strong>
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
var taburl = "";
|
let taburl = "";
|
||||||
var archive = "";
|
|
||||||
|
const txttags = document.getElementById("txttags");
|
||||||
|
const chkarchive = document.getElementById("chkarchive");
|
||||||
|
const btnadd = document.getElementById("btnadd");
|
||||||
|
const msgstatus = document.getElementById("msgstatus");
|
||||||
|
const msgerror = document.getElementById("msgerror");
|
||||||
|
|
||||||
|
|
||||||
function set_taburl(tabs) // Set taburl to URL of current tab.
|
function set_taburl(tabs) // Set taburl to URL of current tab.
|
||||||
{
|
{
|
||||||
let tab = tabs[0];
|
const tab = tabs[0];
|
||||||
taburl = tab.url;
|
taburl = tab.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_tags() // get tags from text input.
|
function get_tags() // get tags from text input.
|
||||||
{
|
{
|
||||||
let tags = txttags.value;
|
const tags = txttags.value;
|
||||||
if (tags != "")
|
if (tags != "")
|
||||||
{
|
{
|
||||||
return "-t '" + tags + "' ";
|
return "-t '" + tags + "' ";
|
||||||
|
@ -19,12 +25,12 @@ function get_tags() // get tags from text input.
|
||||||
|
|
||||||
function read_options()
|
function read_options()
|
||||||
{
|
{
|
||||||
var item = browser.storage.sync.get('archive');
|
const item = browser.storage.sync.get('archive');
|
||||||
item.then((res) =>
|
item.then((res) =>
|
||||||
{
|
{
|
||||||
if (res.archive === false)
|
if (res.archive === false)
|
||||||
{
|
{
|
||||||
archive = "--no-archive ";
|
chkarchive.checked = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,14 +61,20 @@ function launch(args) // Launch wrapper and send tags + URL to stdin.
|
||||||
msgstatus.textContent = "Launching remwharead…";
|
msgstatus.textContent = "Launching remwharead…";
|
||||||
msgerror.textContent = "";
|
msgerror.textContent = "";
|
||||||
console.log("Sending: " + args + " to remwharead");
|
console.log("Sending: " + args + " to remwharead");
|
||||||
var sending = browser.runtime.sendNativeMessage("remwharead", args);
|
const sending = browser.runtime.sendNativeMessage("remwharead", args);
|
||||||
sending.then(onResponse, onError);
|
sending.then(onResponse, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add()
|
function add()
|
||||||
{
|
{
|
||||||
var arguments = get_tags() + archive + taburl;
|
let archive = "";
|
||||||
launch(arguments);
|
if (chkarchive.checked === false)
|
||||||
|
{
|
||||||
|
archive = "--no-archive ";
|
||||||
|
}
|
||||||
|
const args = get_tags() + archive + taburl;
|
||||||
|
console.log(args);
|
||||||
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
read_options();
|
read_options();
|
||||||
|
@ -70,7 +82,7 @@ read_options();
|
||||||
// Call set_taburl() with current tab.
|
// Call set_taburl() with current tab.
|
||||||
browser.tabs.query({currentWindow: true, active: true}).then(set_taburl);
|
browser.tabs.query({currentWindow: true, active: true}).then(set_taburl);
|
||||||
|
|
||||||
btnadd.addEventListener("click", launch);
|
btnadd.addEventListener("click", add);
|
||||||
|
|
||||||
txttags.addEventListener( // Call launch() if enter is hit in text input.
|
txttags.addEventListener( // Call launch() if enter is hit in text input.
|
||||||
"keyup", event =>
|
"keyup", event =>
|
||||||
|
@ -79,6 +91,6 @@ txttags.addEventListener( // Call launch() if enter is hit in text input.
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
launch();
|
add();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,7 +64,7 @@ const html_extract URI::get()
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
extract_title(answer),
|
extract_title(answer),
|
||||||
extract_description(answer),
|
strip_html(extract_description(answer)),
|
||||||
strip_html(answer)
|
strip_html(answer)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue