No Google Doodle

Get rid of Google Doodle logos and link

当前为 2021-04-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         No Google Doodle
// @namespace    https://github.com/Procyon-b
// @version      0.6
// @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=false, fixed=false, style='<style>#replacedDoodle ~ div, #replacedDoodle ~ canvas {display:none;}</style>';

var st=document.createElement("style");
st.textContent='#hplogo > *:not(#replacedDoodle), a > img#hplogo {display: none;}'+style;
try{document.head.appendChild(st);}catch(e){}

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') || fixed ) return;
  fixed=true;
  logo=document.querySelector('div#hplogo');
  if (!logo) {
    if (logo = document.querySelector('a > img#hplogo')) {
      logo=logo.parentNode;
      outer=true;
      }
    }
  if (logo) {
    let h='<img id="replacedDoodle" style="bottom:0;position:absolute;left:50%;transform:translate(-50%);" src="/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">'+style;
    if (outer) logo.outerHTML=h;
    else logo.innerHTML=h;
    setTimeout(function(){
      var a=document.querySelectorAll('#replacedDoodle ~ :not(style)');
      a.forEach(function(e){ e.remove(); });
      }, 300);
    }
  else {
    st.remove();
    }
  }

})();