Switched to using localStorage; incremented version to 1.2.6
This commit is contained in:
parent
f01140cf1c
commit
de2d5d0af2
@ -127,7 +127,7 @@ function beginKillingStickies() {
|
||||
/******************/
|
||||
|
||||
function initialize() {
|
||||
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
let shouldKillSticky = checkForShouldKillSticky(result);
|
||||
updateIcon(shouldKillSticky);
|
||||
if (shouldKillSticky) {
|
||||
|
||||
@ -49,18 +49,25 @@ function saveChanges() {
|
||||
let matchingPatterns = document.querySelector("#matchingPatterns textarea").value;
|
||||
let exclusionPatterns = document.querySelector("#exclusionPatterns textarea").value;
|
||||
let mode = document.querySelector("input#whitelist-mode").checked ? "whitelist" : "blacklist";
|
||||
chrome.storage.sync.set({
|
||||
chrome.storage.local.set({
|
||||
"matchingPatterns": matchingPatterns,
|
||||
"exclusionPatterns": exclusionPatterns,
|
||||
"mode": mode
|
||||
}, () => { setButtonsActive(false); });
|
||||
}, () => {
|
||||
let error = chrome.runtime.lastError;
|
||||
if (error) {
|
||||
alert(error.message);
|
||||
} else {
|
||||
setButtonsActive(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Retrieves the saved state from storage and reset the UI to reflect it,
|
||||
discarding the user's changes.
|
||||
*/
|
||||
function resetChanges(callback) {
|
||||
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
AKS.matchingPatterns = result.matchingPatterns || "";
|
||||
AKS.exclusionPatterns = result.exclusionPatterns || ""
|
||||
AKS.mode = result.mode || "blacklist";
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "AlwaysKillSticky",
|
||||
"version": "1.2.5.2",
|
||||
"version": "1.2.6",
|
||||
"description": "Get rid of sticky elements on websites - permanently!",
|
||||
"author": "Said Achmiz",
|
||||
"homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git",
|
||||
"permissions": [ "activeTab", "storage" ],
|
||||
"permissions": [ "activeTab", "storage", "unlimitedStorage" ],
|
||||
"background": {
|
||||
"scripts": ["background.js"],
|
||||
"persistent": false
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "AlwaysKillSticky",
|
||||
"version": "1.2.5.2",
|
||||
"version": "1.2.6",
|
||||
"description": "Get rid of sticky elements on websites - permanently!",
|
||||
"author": "Said Achmiz",
|
||||
"browser_specific_settings": {
|
||||
@ -11,7 +11,7 @@
|
||||
}
|
||||
},
|
||||
"homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git",
|
||||
"permissions": [ "activeTab", "storage" ],
|
||||
"permissions": [ "activeTab", "storage", "unlimitedStorage" ],
|
||||
"background": {
|
||||
"scripts": [ "background.js" ]
|
||||
},
|
||||
|
||||
12
src/popup.js
12
src/popup.js
@ -219,7 +219,7 @@ function initialize() {
|
||||
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
||||
AKS.activeTabLocation = tabs[0].url;
|
||||
AKS.activeTabID = tabs[0].id;
|
||||
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
|
||||
updateState(result);
|
||||
updateUIState();
|
||||
});
|
||||
@ -228,7 +228,7 @@ function initialize() {
|
||||
// Listener for main button.
|
||||
document.querySelector("button.main-button").addActivateEvent((event) => {
|
||||
/* This doesn’t actually kill the stickies yet; that’s below, in the
|
||||
callback to storage.sync.set. */
|
||||
callback to storage.local.set. */
|
||||
toggleState();
|
||||
|
||||
// Prepare the changes for saving.
|
||||
@ -240,7 +240,13 @@ function initialize() {
|
||||
changes.matchingPatterns = AKS.matchingPatterns.join("\n");
|
||||
|
||||
// Save the changes.
|
||||
chrome.storage.sync.set(changes, () => {
|
||||
chrome.storage.local.set(changes, () => {
|
||||
let error = chrome.runtime.lastError;
|
||||
if (error) {
|
||||
alert(error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the UI, once changes are saved.
|
||||
updateUIState();
|
||||
let reloadButton = document.querySelector("button.reload-button");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user