Read in Immersive Reader
От
// ==UserScript==
// @name Immersive Reader
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Read in Immersive Reader
// @author You
// @match https://*/*
// @match http://*/*
// @match read://*
// @icon https://www.google.com/s2/favicons?sz=64&domain=readfog.com
// @grant GM_registerMenuCommand
// @run-at document-start
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function getPageURL(url) {
if (typeof url != 'string') return null;
const m1 = /^https:\/\/www\.signalhire\.com\/sorry\?continue=([^=&]+)/.exec(url);
let eurl = ''; // URIComponent
if (m1) eurl = m1[1];
try {
if (eurl && typeof eurl == 'string') url = decodeURIComponent(eurl); // avoid URI malformed
} catch (e) {}
return url;
}
function turnPlain() {
const url = getPageURL(location.href);
const nurl = `read://${url}`
let mystring = `<html><a href="${nurl}">Drag me to url for Immersive Reader</a></html>`;
let myblob = new Blob([mystring], {
type: 'text/html'
});
mystring = "";
let murl = URL.createObjectURL(myblob);
let div = document.createElement('div');
div.innerHTML=`<a href="${nurl}">
<div style="display:flex;
position:fixed; top:30vh; left:30vw;
background:#000;color:#fff !important;
font-size:38pt;z-index:999;width:40vw;height:40vh;
align-items: center; text-align: center;
overflow: hidden; border:5px solid #ddd;
letter-spacing: 4pt;
">
right click to open in new tab/window
</div></a>`
document.documentElement.appendChild(div)
div.onclick=function(){
setTimeout(function(){
div.remove()
},30);
}
div.oncontextmenu=function(){
setTimeout(function(){
div.remove()
},30);
}
}
if (!/^read:\/\//.test(location.href)) {
new Promise(() => {
GM_registerMenuCommand("Switch to Immersive Reader", turnPlain, "I");
})
}
})();