Chrome support

This commit is contained in:
Kevin Röbert
2019-04-01 23:53:28 +02:00
parent 869cd63e64
commit 03e0580b20
13 changed files with 143 additions and 997 deletions

View File

@@ -35,7 +35,7 @@ function handleMessage(request, sender, sendResponse)
{
var response = fn.apply(null, request.params);
sendResponse({response});
return Promise.resolve({response});
}
}

View File

@@ -35,27 +35,60 @@ var currentURL;
async function getData()
{
await browser.runtime.sendMessage({
function: "getEntireData",
function: "getData",
params: ["globalCounter"]
}).then((data) => {
globalCounter = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["globalurlcounter"]
}).then((data) => {
globalurlcounter = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["globalStatus"]
}).then((data) => {
globalStatus = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["badgedStatus"]
}).then((data) => {
badgedStatus = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["hashStatus"]
}).then((data) => {
hashStatus = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["loggingStatus"]
}).then((data) => {
loggingStatus = data.response;
});
await browser.runtime.sendMessage({
function: "getData",
params: ["statisticsStatus"]
}).then((data) => {
statisticsStatus = data.response;
});
await browser.runtime.sendMessage({
function: "getCurrentURL",
params: []
}).then((data) => {
data = data.response;
globalCounter = data.globalCounter;
globalurlcounter = data.globalurlcounter;
globalStatus = data.globalStatus;
badgedStatus = data.badgedStatus;
hashStatus = data.hashStatus;
loggingStatus = data.loggingStatus;
statisticsStatus = data.statisticsStatus;
browser.runtime.sendMessage({
function: "getCurrentURL",
params: []
}).then((data) => {
currentURL = data.response;
return null;
}, handleError);
}, handleError);
currentURL = data.response;
});
}
/**

View File

@@ -1,24 +1,24 @@
/*
* ClearURLs
* Copyright (c) 2017-2019 Kevin Röbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* ClearURLs
* Copyright (c) 2017-2019 Kevin Röbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*jshint esversion: 6 */
/*
* This script is responsible for the storage.
* This script is responsible for the storage.
*/
var storage = [];
@@ -61,7 +61,7 @@ function saveOnDisk(key, value)
*/
function getDataFromDisk()
{
browser.storage.local.get().then(initStorage, error);
browser.storage.local.get(null).then(initStorage, error);
}
/**
@@ -75,9 +75,9 @@ function getData(key)
}
/**
* Return the entire storage object.
* @return {Object}
*/
* Return the entire storage object.
* @return {Object}
*/
function getEntireData()
{
return storage;
@@ -152,8 +152,13 @@ function initSettings()
storage.badged_color = "ffa500";
storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/-/jobs/artifacts/master/raw/rules.min.hash?job=hash%20rules";
storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.min.json";
storage.types = ["font", "image", "imageset", "main_frame", "media", "object", "object_subrequest", "other", "script", "stylesheet", "sub_frame", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt"];
storage.reportServer = "https://clearurls.xn--rb-fka.it";
if(getBrowser() === "Firefox") {
storage.types = ["font", "image", "imageset", "main_frame", "media", "object", "object_subrequest", "other", "script", "stylesheet", "sub_frame", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt"];
} else if (getBrowser() === "Chrome") {
storage.types = ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"];
}
}
/**

View File

@@ -69,7 +69,7 @@ function reload()
*/
function checkOSAndroid()
{
browser.runtime.getPlatformInfo().then(function(info) {
chrome.runtime.getPlatformInfo(function(info) {
os = info.os;
});
@@ -207,3 +207,14 @@ function getCurrentURL()
{
return currentURL;
}
/**
* Check for browser.
*/
function getBrowser() {
if(typeof InstallTrigger !== 'undefined') {
return "Firefox";
} else {
return "Chrome";
}
}