Background script for setting default options on install
This commit is contained in:
parent
d7b3e01577
commit
bbc18f90de
41
js/background.js
Normal file
41
js/background.js
Normal file
@ -0,0 +1,41 @@
|
||||
chrome.runtime.onInstalled.addListener(function () {
|
||||
let settings = {
|
||||
hotkeys: {
|
||||
codes: {
|
||||
slower: ["F21"],
|
||||
normal: ["F22"],
|
||||
faster: ["F23"],
|
||||
pause: ["k"],
|
||||
"skip-back": ["ArrowLeft"],
|
||||
"skip-forward": ["ArrowRight"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
chrome.storage.local.set({ "extension-settings": settings }, function () {
|
||||
console.log("Initial setting set...");
|
||||
});
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
if (msg.from === "content" && msg.subject === "changeIcon") {
|
||||
// let canvas = document.getElementById("icon-making-canvas");
|
||||
// if (!canvas) {
|
||||
// canvas = document.createElement("CANVAS");
|
||||
// canvas.id = "icon-making-canvas";
|
||||
// canvas.width = canvas.height = 16;
|
||||
// }
|
||||
// let ctx = canvas.getContext("2d");
|
||||
// ctx.beginPath();
|
||||
// ctx.rect(0, 0, 16, 16);
|
||||
// ctx.fillStyle = "red";
|
||||
// ctx.fill();
|
||||
// ctx.fillStyle = "white";
|
||||
// ctx.textAlign = "center";
|
||||
// ctx.textBaseline = "middle";
|
||||
// fitTextOnCanvas(ctx, msg.speed, "Roboto Condensed", 9, canvas.width);
|
||||
// let imgData = ctx.getImageData(0, 0, 16, 16);
|
||||
// chrome.pageAction.setIcon({ imageData: imgData, tabId: sender.tab.id });
|
||||
}
|
||||
return Promise.resolve("Dummy response to keep the console quiet");
|
||||
});
|
@ -3,7 +3,12 @@
|
||||
"js": [ "dist/raw/spatial-navigation.js" ],
|
||||
"matches": [ "\u003Call_urls>" ],
|
||||
"run_at": "document_end"
|
||||
} ],
|
||||
}
|
||||
],
|
||||
"background": {
|
||||
"scripts": ["js/background.js"],
|
||||
"persistent": false
|
||||
},
|
||||
"icons": {
|
||||
"32": "dist/raw/icon.png"
|
||||
},
|
||||
@ -14,6 +19,6 @@
|
||||
"permissions": ["\u003Call_urls>"],
|
||||
"short_name": "spatial-navigation",
|
||||
"update_url": "https://clients2.google.com/service/update2/crx",
|
||||
"version": "0.4.7"
|
||||
"version": "0.4.7",
|
||||
"options_page": "options.html"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user