🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Wayback Machine - toolbar toggler

A way to toggle the WaybackMachine's toolbar

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Wayback Machine - toolbar toggler
// @name:fr      Wayback Machine - (dé)masquer la barre d'outils
// @namespace    https://github.com/Procyon-b
// @version      0.8
// @description  A way to toggle the WaybackMachine's toolbar
// @description:fr  Une méthode pour masquer/afficher la barre d'outils de WaybackMachine (web.archive.org)
// @author       Achernar
// @match        *://web.archive.org/web/*
// @grant        none
// @run-at       document-start
// @noframes
// ==/UserScript==

(function() {
"use strict";

function addStyle(e,s) {
  if (!e) return;
  var st=document.createElement("style");
  st.textContent=s;
  e.appendChild(st);
  }

function fix(ev) {
  var TO, st, sts = document.getElementsByTagName('style');
  addStyle( (document.head || document.documentElement), '#wm-ipp-base {opacity:0; min-height:1px;position:absolute;} #wm-ipp-base:hover {opacity: 1;} #wm-ipp-base.forcePriority {oposition:relative; z-index:99999;} body > #wm-ipp-print, body> #donato {display: none;}');

  // remove this style if present
  for (st of sts) {
    try{
    if (st.innerText.search('.wb-autocomplete-suggestions')+1) {
      st.innerText='';
      break;
      }
    }catch(e){}
    }

  // remove all added styles
  var wbSt, del=[];
  for (let el of document.body.childNodes) {
    if (el.nodeType==8) {
      if (!wbSt && (el.data==' BEGIN WAYBACK TOOLBAR INSERT ')) wbSt=true;
      else if (wbSt && (el.data==' END WAYBACK TOOLBAR INSERT ')) {
        for (let i=0; i<del.length; i++) del[i].parentNode.removeChild(del[i]);
        break;
        }
      continue;
      }
    if (!wbSt) continue;
    if (el.nodeName=='STYLE') del.push(el);
    }

  // remove archive.org stylesheets
  sts=document.querySelectorAll('link[rel=stylesheet]');
  for (st of sts) {
    if (st.href.startsWith('https://web.archive.org/_static/') && !(st.href.search('/iconochive.css')+1) ) {
      st.parentNode.removeChild(st);
      }
    }

  // change "close" icon color
  if (!sr) sr=e.sr;
  if (sr) {
    let s='#wm-tb-close .iconochive-remove-circle {color: #26d926 !important;}';
    try{ addStyle(sr, s);
    }catch(er){
      let st=document.createElement('style');
      st.textContent=s;
      sr.appendChild(st);
      }
    }

  this.removeEventListener('dblclick', fix);
  document.body.addEventListener('keydown',function(ev){
    force=ev.altKey && ev.ctrlKey;
    if (force && !forceState) {
      e.classList.add('forcePriority');
      forceState=force;
      if (TO) clearTimeout(TO);
      TO=setTimeout(function(){
        e.classList.remove('forcePriority');
        forceState=false;
        TO=0;
        },3000);

      if (sr) {
        let e = sr.querySelector('[style*="display: none;"]')
        if (e) e.style.display='';
        }
      }
    });
  }

var e=document.getElementById('wm-ipp-base'), initCnt=100, sr, TO, force=false, forceState=false;

var obs = new MutationObserver(function(mutL) {
  for (let mut of mutL) {
    let e=mut.addedNodes[0];
    if (e && (e.id=='wm-ipp-base')) {
      if (TO) clearTimeout(TO);
      obs.disconnect();
      init();
      }
    }
  });
//obs.observe(document.documentElement, {attributes: false, subtree: true, childList: true });

function init() {
  e=document.getElementById('wm-ipp-base');
  if (!e) {
    if (--initCnt > 0) TO=setTimeout(init, 50);
    else if (initCnt > -5) TO=setTimeout(init, 3000);
    return;
    }
  obs.disconnect();

  e.addEventListener('dblclick', fix);
  let ne=e.nextElementSibling;
  if (ne && (ne.id=='donato')) ne.parentNode.removeChild(ne);
  }
//init();

// catch attachShadow
var s=document.createElement('script');
s.textContent=`(function(){
var options={attributes: false, subtree: true, childList: true };
var obs = new MutationObserver(function(mutL) {
  for (let mut of mutL) {
    let e=mut.addedNodes[0];
    if (e && (e.id=='wm-ipp-base')) {
      var oldAS=e.attachShadow;
      e.attachShadow=function(m){
        e.sr=oldAS.call(e,m);
        return e.sr;
        }
      obs.disconnect();
      }
    }
});
obs.observe(document.documentElement, options);
})()`;

var injected=0;
function inject() {
  if (injected++) return;

  var sc=document.documentElement.insertBefore(s,document.head);
  sc.parentNode.removeChild(sc);
  }

var started=0;
function start() {
  if (started++) return;
  inject();
  init();
  obs.observe(document.documentElement, {attributes: false, subtree: true, childList: true });
}

tryUntil(inject, 0);
tryUntil(function(){
  obs.observe(document.documentElement, {attributes: false, subtree: true, childList: true });
  }, 0);

function tryUntil(F, TO=150, c=-1, fail) {
  if (!c--) {
    fail && fail();
    return;
    }
  try{F();}catch(e){setTimeout(function(){tryUntil(F,TO,c,fail);}, TO)}
  }

if (document.readyState != 'loading') start();
else {
  document.addEventListener('DOMContentLoaded', start);
  window.addEventListener('load', start);
  }


})();