Compare commits
5 Commits
62844f9ac2
...
626e5f932e
Author | SHA1 | Date | |
---|---|---|---|
626e5f932e | |||
77383bad6f | |||
d72e904a20 | |||
2a0c333b9d | |||
232d1e5b30 |
@ -1,12 +1,39 @@
|
||||
function replaceTileserver(request) {
|
||||
var url = request.url.replace("tile.openstreetmap.org", "tiles.demostat.de");
|
||||
console.log("custom-openstreetmap-tile-server: " + request.url + " -> " + url);
|
||||
return {redirectUrl: url};
|
||||
}
|
||||
|
||||
urls = [
|
||||
const urls = [
|
||||
"*://*.tile.openstreetmap.org/*"
|
||||
]
|
||||
|
||||
var tileserver_url = "";
|
||||
|
||||
function log(msg) {
|
||||
console.log("custom-openstreetmap-tile-server: " + msg)
|
||||
}
|
||||
|
||||
function setTileserver(storage) {
|
||||
tileserver_url = storage.tileserver;
|
||||
log("set tileserver_url to " + tileserver_url);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
function updateTileserverUrl() {
|
||||
var getting = browser.storage.local.get("tileserver");
|
||||
getting.then(setTileserver, onError);
|
||||
}
|
||||
|
||||
function replaceTileserver(request) {
|
||||
|
||||
updateTileserverUrl();
|
||||
|
||||
if (tileserver_url == "") {
|
||||
log(request.url + " -> no tileserver_url");
|
||||
return {}
|
||||
}
|
||||
|
||||
var url = request.url.replace("tile.openstreetmap.org", tileserver_url);
|
||||
log(request.url + " -> " + url);
|
||||
return {redirectUrl: url};
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(replaceTileserver, {urls: urls}, ["blocking"]);
|
||||
|
@ -8,7 +8,7 @@ function saveOptions(e) {
|
||||
function restoreOptions() {
|
||||
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelector("#tileserver").value = result.tileserver;
|
||||
document.querySelector("#tileserver").value = result.tileserver || "";
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
|
Loading…
Reference in New Issue
Block a user