1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 04:40:20 +01:00

Fixed relative require paths

This commit is contained in:
kkapsner 2019-04-08 00:02:29 +02:00
parent 9f3da67cf2
commit 12137402de
13 changed files with 51 additions and 30 deletions

View File

@ -4,8 +4,8 @@
(function(){
"use strict";
const logging = require("./logging");
const settings = require("./settings");
const logging = require("../lib/logging");
const settings = require("../lib/settings");
logging.message("Opened browser action");
settings.onloaded(function(){

View File

@ -10,12 +10,13 @@ const require = function(){
const scope = window.scope;
function getScopeName(module){
var scopeName = module.substr(2).replace(/\..+/, "");
var scopeName = module.replace(/^\..*\//, "").replace(/\..+/, "");
// console.log(scopeName);
return scopeName;
}
function require(module){
if (module.startsWith("./")){
if (module.startsWith(".")){
var scopeName = getScopeName(module);
return scope[scopeName];
}

View File

@ -4,9 +4,9 @@
(function(){
"use strict";
const settings = require("./settings");
const logging = require("./logging");
const settingsMigration = require("./settingsMigration");
const settings = require("../lib/settings");
const logging = require("../lib/logging");
const settingsMigration = require("../lib/settingsMigration");
const input = document.getElementById("settings");
settings.onloaded(function(){
var data = {};

View File

@ -4,8 +4,8 @@
(function(){
"use strict";
const settings = require("./settings");
const navigator = require("./navigator");
const settings = require("../lib/settings");
const navigator = require("../lib/navigator");
const title = document.createElement("h1");
title.className = "title";

View File

@ -4,16 +4,16 @@
(function(){
"use strict";
const logging = require("./logging");
const logging = require("../lib/logging");
logging.setPrefix("options page");
const optionsGui = require("./optionsGui");
const settings = require("./settings");
const settingsDisplay = require("./settingsDisplay");
const search = require("./search");
const settingStrings = require("./settingStrings");
const settings = require("../lib/settings");
const settingsDisplay = require("../lib/settingsDisplay");
const search = require("../lib/search");
const settingStrings = require("../lib/settingStrings");
const searchParameters = new URLSearchParams(window.location.search);
const settingsMigration = require("./settingsMigration");
const settingsMigration = require("../lib/settingsMigration");
var callbacks = {
openNavigatorSettings: function(){

View File

@ -12,7 +12,7 @@
scope = require.register("./optionsGui", {});
}
const logging = require("./logging");
const logging = require("../lib/logging");
function createDescription(setting){
var c = document.createElement("div");

View File

@ -12,7 +12,7 @@
scope = require.register("./sanitationRules", {});
}
const settings = require("./settings");
const settings = require("../lib/settings");
scope.ruleset = [
{

View File

@ -4,7 +4,7 @@
(function(){
"use strict";
const settings = require("./settings");
const settings = require("../lib/settings");
const sanitationRules = require("./sanitationRules");
var title = document.createElement("h1");

View File

@ -5,6 +5,7 @@
"use strict";
const {createCollapser, createActionButtons} = require("./gui");
const extension = require("../lib/extension");
const actions = [];
const addAction = function addAction(action){
@ -13,7 +14,7 @@
const addToContainer = function(){
const container = document.getElementById("prints");
container.querySelector("li").textContent = browser.i18n.getMessage("pleaseWait");
container.querySelector("li").textContent = extension.getTranslation("pleaseWait");
var first = true;
return function addToContainer(domainNotification){
@ -103,7 +104,7 @@
this.textNode = function(){
return node;
};
var messageParts = browser.i18n.getMessage(this.messageId).split(/\{url\}/g);
var messageParts = extension.getTranslation(this.messageId).split(/\{url\}/g);
node.appendChild(document.createTextNode(messageParts.shift()));
while (messageParts.length){
var urlSpan = document.createElement("span");
@ -179,5 +180,10 @@
return domainNotification;
};
domainNotification.addAction = addAction;
require.register("./domainNotification", domainNotification);
if ((typeof module) !== "undefined"){
module.exports = domainNotification;
}
else {
require.register("./domainNotification", domainNotification);
}
}());

View File

@ -5,14 +5,21 @@
(function(){
"use strict";
const scope = require.register("./gui", {});
let scope;
if ((typeof exports) !== "undefined"){
scope = exports;
}
else {
scope = require.register("./gui", {});
}
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("./logging");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("../lib/logging");
const extension = require("../lib/extension");
scope.createCollapser = function(){
const messages = {
more: browser.i18n.getMessage("more"),
less: browser.i18n.getMessage("less")
more: extension.getTranslation("more"),
less: extension.getTranslation("less")
};
return function createCollapser(container){

View File

@ -72,5 +72,11 @@
update(){}
}
Notification.addAction = addAction;
require.register("./Notification", Notification);
if ((typeof module) !== "undefined"){
module.exports = Notification;
}
else {
require.register("./Notification", Notification);
}
}());

View File

@ -11,6 +11,7 @@
<li>...</li>
</ul>
<script src="../lib/require.js"></script>
<script src="../lib/extension.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settingContainers.js"></script>

View File

@ -4,15 +4,15 @@
(function(){
"use strict";
const settings = require("./settings");
const {parseErrorStack} = require("./callingStack");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("./logging");
const settings = require("../lib/settings");
const {parseErrorStack} = require("../lib/callingStack");
const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = require("../lib/logging");
setLogPrefix("page action script");
const domainNotification = require("./domainNotification");
const Notification = require("./Notification");
const {createActionButtons, modalPrompt, modalChoice} = require("./gui");
const lists = require("./lists");
const lists = require("../lib/lists");
Promise.all([
browser.tabs.query({active: true, currentWindow: true}),