Greasy Fork 支持简体中文。

No Google Doodle

Get rid of Google Doodle logos and link

目前為 2021-09-03 提交的版本,檢視 最新版本

// ==UserScript==
// @name         No Google Doodle
// @namespace    https://github.com/Procyon-b
// @version      0.6.4
// @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*
// @include      /^https:\/\/www\.google\.co\.[^.]+\//
// @include      /^https:\/\/www\.google\.co\.[^.]+\/\?.*/
// @include      /^https:\/\/www\.google\.co\.[^.]+\/webhp.*/
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
"use strict";

var logo, outer=false, fixed=false, style='#replacedDoodle ~ div, #replacedDoodle ~ canvas {display:none;}';

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(':scope a img#hplogo')) {
      logo=logo.closest('a');
      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>'+style+'</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();
    }
  }

})();