1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

Added centralized theme system and themed all pages

This commit is contained in:
kkapsner 2019-05-02 00:30:30 +02:00
parent c2a817478e
commit 6301b744d2
39 changed files with 448 additions and 127 deletions

38
lib/theme.js Normal file
View file

@ -0,0 +1,38 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
"use strict";
let scope;
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
scope = require.register("./theme", {});
}
const settings = require("./settings");
scope.init = function(page){
const basePath = browser.extension.getURL("themes");
settings.onloaded(function(){
const links = ["layout", page].filter(function(file){
return file;
}).map(function(file){
var link = document.createElement("link");
link.cbFile = file;
link.href = `${basePath}/${settings.theme}/${file}.css`;
link.rel = "stylesheet";
link.type = "text/css";
document.head.appendChild(link);
return link;
});
settings.on("theme", function(){
links.forEach(function(link){
link.href = `${basePath}/${settings.theme}/${link.cbFile}.css`;
});
});
});
};
}());