Régi: v25.11.08 - 2025.11.08. - Improve interface.
Új: v25.11.17 - 2025.11.17. - Fixed functionality with servers that require, so called, "trusted HTML assignment".
- @@ -12,7 +12,7 @@
- // @namespace i2p.schimon.proxy-redirect
- // @description Redirect to privacy respecting proxy frontends
- // @run-at document-start
-// @version 25.11.08
- +// @version 25.11.17
- // @grant GM.getValue
- // @grant GM.registerMenuCommand
- // @grant GM.setValue
- @@ -2194,7 +2194,23 @@
- // /questions/6464592/how-to-align-entire-html-body-to-the-center
- const loadPage = '<html xmlns="http://www.w3.org/1999/xhtml" style="display:table;margin:auto;"><head><link type="image/svg+xml" rel="shortcut icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22> <text y=%22.9em%22 font-size=%2290%22>🥸</text> </svg>"/><title>Proxy Redirect</title></head><body style="padding:1em;display:table-cell;height:100%;background-color:#f1f1f1;font-family:system-ui;cursor:default;user-select:none;max-height:100%;max-width:100%;"><dl><dt><h1>🥸 Proxy Redirect</h1></dt><dd><h2>The request is being redirected to a privacy proxy frontend.</h2><div id="message"><h3 style="color:#0000ff;">Redirecting...</h3></div><div>Made for <a href="https://falkon.org">Falkon</a></div></dd></dl></body></html>';
- const domParser = new DOMParser();
- const newDocument = domParser.parseFromString(loadPage, 'text/html');
- + let newDocument;
- + try {
- + newDocument = domParser.parseFromString(loadPage, 'text/html');
- + } catch (e) {
- + console.warn(e);
- + // TODO Recognize TrustedHTML, as or similarly to "securitypolicyviolation".
- + if (e.toString().includes("TypeError") && e.toString().includes("TrustedHTML")) {
- + // Thank you. hacker09.
- + // https://greasyfork.org/en/discussions/development/220765#comment-469969
- + if (window.trustedTypes && window.trustedTypes.createPolicy) {
- + window.trustedTypes.createPolicy("default", {
- + createHTML: (string, sink) => string
- + });
- + }
- + newDocument = domParser.parseFromString(loadPage, 'text/html');
- + }
- + }
- +
- //newDocument.querySelector('#icon-tc').onclick = () => {disable()}; // FIXME
- //newDocument.querySelector('#icon-tc').addEventListener("click", disable, false);
- const insertDocument = document.importNode(newDocument.documentElement, true);