mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-18 09:28:15 +00:00
Update options_custom.js (FF browser-api)
This commit is contained in:
parent
32864d7502
commit
de43bdcd50
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
// Saves options to chrome.storage
|
// Saves options to browser.storage
|
||||||
function save_options() {
|
function save_options() {
|
||||||
var gh_url = document.getElementById('bypass_sites').value;
|
var gh_url = document.getElementById('bypass_sites').value;
|
||||||
var textareaEl = document.querySelector('#bypass_sites textarea');
|
var textareaEl = document.querySelector('#bypass_sites textarea');
|
||||||
var sites_custom = {};
|
var sites_custom = {};
|
||||||
if (textareaEl.value !== '')
|
if (textareaEl.value !== '')
|
||||||
var sites_custom = JSON.parse(textareaEl.value);
|
var sites_custom = JSON.parse(textareaEl.value);
|
||||||
chrome.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
sites_custom: sites_custom
|
sites_custom: sites_custom
|
||||||
}, function () {
|
}, function () {
|
||||||
// Update status to let user know custom sites were saved.
|
// Update status to let user know custom sites were saved.
|
||||||
@ -20,7 +20,7 @@ function save_options() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add custom site to chrome.storage
|
// Add custom site to browser.storage
|
||||||
function add_options() {
|
function add_options() {
|
||||||
var gh_url = document.getElementById('add_site').value;
|
var gh_url = document.getElementById('add_site').value;
|
||||||
var inputEls = document.querySelectorAll('#add_site input');
|
var inputEls = document.querySelectorAll('#add_site input');
|
||||||
@ -46,7 +46,7 @@ function add_options() {
|
|||||||
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace('www.', '');
|
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace('www.', '');
|
||||||
|
|
||||||
// add new site to local storage
|
// add new site to local storage
|
||||||
chrome.storage.sync.get({
|
browser.storage.sync.get({
|
||||||
sites_custom: {}
|
sites_custom: {}
|
||||||
}, function (items) {
|
}, function (items) {
|
||||||
var sites_custom_old = items.sites_custom;
|
var sites_custom_old = items.sites_custom;
|
||||||
@ -55,7 +55,7 @@ function add_options() {
|
|||||||
sites_custom_old[key] = sites_custom[key];
|
sites_custom_old[key] = sites_custom[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
sites_custom: sites_custom_old
|
sites_custom: sites_custom_old
|
||||||
}, function () {
|
}, function () {
|
||||||
// Update status to let user know new custom site was added.
|
// Update status to let user know new custom site was added.
|
||||||
@ -71,7 +71,7 @@ function add_options() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete custom site to chrome.storage
|
// Delete custom site to browser.storage
|
||||||
function delete_options() {
|
function delete_options() {
|
||||||
var gh_url = document.getElementById('custom_sites').value;
|
var gh_url = document.getElementById('custom_sites').value;
|
||||||
var selectEl = document.querySelector('#custom_sites select');
|
var selectEl = document.querySelector('#custom_sites select');
|
||||||
@ -79,13 +79,13 @@ function delete_options() {
|
|||||||
var remove_key = selectEl.value;
|
var remove_key = selectEl.value;
|
||||||
|
|
||||||
// delete site from local storage
|
// delete site from local storage
|
||||||
chrome.storage.sync.get({
|
browser.storage.sync.get({
|
||||||
sites_custom: {}
|
sites_custom: {}
|
||||||
}, function (items) {
|
}, function (items) {
|
||||||
var sites_custom_old = items.sites_custom;
|
var sites_custom_old = items.sites_custom;
|
||||||
delete sites_custom_old[remove_key];
|
delete sites_custom_old[remove_key];
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
browser.storage.sync.set({
|
||||||
sites_custom: sites_custom_old
|
sites_custom: sites_custom_old
|
||||||
}, function () {
|
}, function () {
|
||||||
// Update status to let user know custom site was deleted.
|
// Update status to let user know custom site was deleted.
|
||||||
@ -101,9 +101,9 @@ function delete_options() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restores checkbox input states using the preferences stored in chrome.storage.
|
// Restores checkbox input states using the preferences stored in browser.storage.
|
||||||
function renderOptions() {
|
function renderOptions() {
|
||||||
chrome.storage.sync.get({
|
browser.storage.sync.get({
|
||||||
sites_custom: {}
|
sites_custom: {}
|
||||||
}, function (items) {
|
}, function (items) {
|
||||||
var sites_custom = items.sites_custom;
|
var sites_custom = items.sites_custom;
|
||||||
|
Loading…
Reference in New Issue
Block a user