mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 06:05:37 +07:00
Chrome support
This commit is contained in:
@@ -35,7 +35,7 @@ function handleMessage(request, sender, sendResponse)
|
||||
{
|
||||
var response = fn.apply(null, request.params);
|
||||
|
||||
sendResponse({response});
|
||||
return Promise.resolve({response});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user