jcunews

Hidden Site Bookmarklet

Jun 7th, 2021
610
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* context: https://www.reddit.com/r/operabrowser/comments/ntgbhd/how_to_remove_this/h0t5xp6/ */
  2. javascript: /*HiddenSite*/
  3. (() => {
  4.   let url = "https://en.wikipedia.org", db = document.body, b = window.hidSite, o = window.hidSiteOverlay,
  5.     getEles = () => {
  6.       b = hidSite; o = window.hidSiteOverlay
  7.     },
  8.     hide = () => {
  9.       getEles();
  10.       b.style.cssText = "display:none!important";
  11.       o && o.remove();
  12.       db.classList.remove("sbshow")
  13.     };
  14.   if (o) {
  15.     hide()
  16.   } else if (b) {
  17.     if (b.style.display) {
  18.       b.style.display = "";
  19.       db.classList.add("sbshow")
  20.     } else {
  21.       b.insertAdjacentHTML("beforeend", `<div id="hidSiteOverlay"><div id="hidSitePrompt">
  22. <button id="hide">Hide Hidden Site</button><button id="close">Close Hidden Site</button></div></div>`);
  23.       hidSiteOverlay.focus()
  24.     }
  25.   } else {
  26.     db.insertAdjacentHTML("beforeend", `<div id="hidSite"><style>body.sbshow>*{display:none!important}${
  27. `#hidSite,#hidSite *{all:revert}
  28. #hidSiteFrame{position:fixed;left:0;top:0;border:none;box-sizing:border-box;width:100vw;height:100vh}
  29. #hidSiteOverlay{position:fixed;left:0;top:0;width:100vw;height:100vh;background:rgb(0,0,0,.5);cursor:pointer}
  30. #hidSitePrompt{position:fixed;left:50vw;top:1em;transform:translateX(-50%);border:.2em solid #007;border-radius:.5em;padding:1em;background:#fff;cursor:auto}
  31. body:not(.sbshow):after{position:fixed;right:0;bottom:0;border:1px solid #000;width:.3em;height:.3em;background:#ff0;content:""}
  32. #hidSite button{cursor:pointer}
  33. #hidSite #close{margin-left:3em}`.replace(/([;\}])/g, "!important$1")
  34. }</style><iframe id="hidSiteFrame" referrerpolicy="same-origin"></iframe></div>`);
  35.     hidSiteFrame.src = url;
  36.     hidSite.onclick = ev => {
  37.       getEles();
  38.       switch (ev.target.id) {
  39.         case "hide":
  40.           hide(); break;
  41.         case "close":
  42.           b.remove(); db.classList.remove("sbshow"); removeEventListener("blur", hide); break;
  43.         case "hidSiteOverlay":
  44.           o.remove(); hidSiteFrame.focus()
  45.       }
  46.     };
  47.     addEventListener("blur", hide);
  48.     db.classList.add("sbshow");
  49.     hidSiteFrame.focus()
  50.   }
  51. })()
RAW Paste Data