WebExtension: Added option to toggle archiving.
This commit is contained in:
parent
052f67f372
commit
cd5a4ecf31
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "remwharead",
|
||||
"version": "0.2.2",
|
||||
"version": "0.3.0",
|
||||
|
||||
"description": "Integrates remwharead into your Browser.",
|
||||
"homepage_url": "https://schlomp.space/tastytea/remwharead",
|
||||
|
@ -23,7 +23,8 @@
|
|||
"permissions":
|
||||
[
|
||||
"activeTab",
|
||||
"nativeMessaging"
|
||||
"nativeMessaging",
|
||||
"storage"
|
||||
],
|
||||
|
||||
"browser_action":
|
||||
|
@ -40,6 +41,12 @@
|
|||
}]
|
||||
},
|
||||
|
||||
"options_ui":
|
||||
{
|
||||
"page": "options.html",
|
||||
"browser_style": true
|
||||
},
|
||||
|
||||
"commands":
|
||||
{
|
||||
"open_popup":
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
<label for="archive">Use archive.org to archive URIs:</label>
|
||||
<input type="checkbox" id="archive" value="archive" checked/>
|
||||
</form>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
function save_options(e)
|
||||
{
|
||||
browser.storage.sync.set(
|
||||
{
|
||||
archive: document.querySelector("#archive").checked
|
||||
});
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
function restore_options()
|
||||
{
|
||||
var item = browser.storage.sync.get('archive');
|
||||
item.then((res) =>
|
||||
{
|
||||
document.querySelector("#archive").checked = res.archive;
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restore_options);
|
||||
document.querySelector("#archive").addEventListener("change", save_options);
|
|
@ -1,5 +1,5 @@
|
|||
var taburl;
|
||||
var port;
|
||||
var taburl = "";
|
||||
var archive = "";
|
||||
|
||||
function set_taburl(tabs) // Set taburl to URL of current tab.
|
||||
{
|
||||
|
@ -17,6 +17,18 @@ function get_tags() // get tags from text input.
|
|||
return "";
|
||||
}
|
||||
|
||||
function read_options()
|
||||
{
|
||||
var item = browser.storage.sync.get('archive');
|
||||
item.then((res) =>
|
||||
{
|
||||
if (res.archive === false)
|
||||
{
|
||||
archive = "--no-archive ";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onResponse(response) {
|
||||
console.log("Received: " + response);
|
||||
document.getElementById("status").textContent = "";
|
||||
|
@ -42,19 +54,20 @@ function launch() // Launch wrapper and send tags + URL to stdin.
|
|||
{
|
||||
document.getElementById("status").textContent = "Launching remwharead…";
|
||||
document.getElementById("error").textContent = "";
|
||||
var arguments = get_tags() + taburl;
|
||||
var arguments = get_tags() + archive + taburl;
|
||||
console.log("Sending: " + arguments + " to remwharead");
|
||||
var sending = browser.runtime.sendNativeMessage("remwharead", arguments);
|
||||
sending.then(onResponse, onError);
|
||||
}
|
||||
|
||||
read_options();
|
||||
|
||||
// Call set_taburl() with current tab.
|
||||
browser.tabs.query({currentWindow: true, active: true}).then(set_taburl);
|
||||
|
||||
button.addEventListener("click", launch); // Call launch() if button is clicked.
|
||||
|
||||
// Click button if enter is hit in text input.
|
||||
// Call launch if enter is hit in text input.
|
||||
document.querySelector("#tags").addEventListener(
|
||||
"keyup", event =>
|
||||
{
|
||||
|
@ -62,6 +75,6 @@ document.querySelector("#tags").addEventListener(
|
|||
{
|
||||
return;
|
||||
}
|
||||
document.querySelector("#button").click();
|
||||
launch();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue