1
0
Fork 0
cookiedb/userscripts/girlgenius.js

50 Zeilen
1.6 KiB
JavaScript

// ==UserScript==
// @name Girlgenius https fix
// @namespace https://sebastian-tobie.de/
// @version 0.1
// @description converts http to https urls
// @author Sebastian Tobie
// @source https://gitea.sebastian-tobie.de/sebastian/cookiedb/raw/branch/stable/userscripts/girlgenius.js
// @run-at document-body
// @match https://www.girlgeniusonline.com/*
// @grant none
// @unwrap
// ==/UserScript==
function replacehttp(url) {
let u = new URL(url);
console.debug(u.protocol, "http:" == u.protocol)
if(u.protocol == "http:") {
let old = url.href;
u.protocol = "https:";
console.debug("fixed url",old,u.href);
}
return u.toString();
}
(function() {
'use strict';
console.debug("http replacer loaded");
let elements = document.getElementsByTagName("a");
console.info("found", elements.length, "links");
for (let i = 0 ; i<elements.length;i++) {
let el = elements[i];
console.debug("checking", el)
if(el.href == undefined || el.href == "") {
continue
}
el.href = replacehttp(el.href);
console.debug("edited", el)
}
elements = document.getElementsByTagName("img");
console.info("found", elements.length, "images");
for (let i = 0 ; i<elements.length;i++) {
let el = elements[i];
console.debug("checking", el)
if(el.src == undefined || el.src == "") {
console.debug("href == undefined", el.src == undefined , "src == ''",el.src == "")
continue
}
el.src = replacehttp(el.src);
console.debug("edited", el)
}
})();