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