No Google Doodle

Get rid of Google Doodle logos and link

目前為 2021-04-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         No Google Doodle
// @namespace    https://github.com/Procyon-b
// @version      0.5
// @description  Get rid of Google Doodle logos and link
// @author       Achernar
// @include      https://www.google.tld/
// @include      https://www.google.tld/?*
// @include      https://www.google.tld/webhp*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
"use strict";

var logo, outer, style='<style>#replacedDoodle ~ div {display:none;}</style>';

if (document.readyState != 'loading') fix();
else {
  document.addEventListener('DOMContentLoaded', function(){
    obs.disconnect();
    fix();
    });

  const obs = new MutationObserver(function(muts){
    for (let mut of muts) {
      for (let n of mut.addedNodes) {
        if (n.classList && n.classList.contains('o3j99')) {
          if (n.querySelector('#hplogo')) {
            this.disconnect();
            fix();
            return;
            }
          }
        }
      }
    });
  obs.observe(document, { attributes: false, childList: true, subtree: true});
  }

function fix() {
  if (document.title!='Google') return;
  logo=document.querySelector('div#hplogo');
  if (!logo) {
    logo=document.querySelector('a > img#hplogo');
    if (logo) {
      logo=logo.parentNode;
      outer=true;
      }
    }
  if (logo) {
    if (outer) logo.outerHTML = '<img id="replacedDoodle" out style="bottom:0;position:absolute;left:50%;transform:translate(-50%);" src="/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">'+style;
    else logo.innerHTML = '<img id="replacedDoodle" in style="bottom:0;position:absolute;left:50%;transform:translate(-50%);" src="/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">'+style;
    setTimeout(function(){
      var a=document.querySelectorAll('#replacedDoodle ~ :not(style)');
      a.forEach(function(e){ e.remove(); });
      }, 100);
    }
  }

})();