Greasy Fork is available in English.

No Google Doodle

Get rid of Google Doodle logos and link

  1. // ==UserScript==
  2. // @name No Google Doodle
  3. // @namespace https://github.com/Procyon-b
  4. // @version 0.7.6
  5. // @description Get rid of Google Doodle logos and link
  6. // @author Achernar
  7. // @include https://www.google.tld/
  8. // @include https://www.google.tld/?*
  9. // @include https://www.google.tld/webhp*
  10. // @include https://www.google.tld/search?*
  11. // @include /^https:\/\/www\.google\.co\.[^.]+\/$/
  12. // @include /^https:\/\/www\.google\.co\.[^.]+\/\?.*/
  13. // @include /^https:\/\/www\.google\.co\.[^.]+\/webhp.*/
  14. // @include /^https:\/\/www\.google\.co\.[^.]+\/search\?.*/
  15. // @run-at document-start
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. "use strict";
  21.  
  22. function addSt(s) {
  23. if (!s) return;
  24. var r=document.documentElement || document.head;
  25. if (!r) {
  26. setTimeout(function(){addSt(s)},0);
  27. return;
  28. }
  29. st=document.createElement('style');
  30. r.appendChild(st);
  31. st.textContent=s;
  32. }
  33.  
  34. var st, logo, outer=false, fixed=false, style='#replacedDoodle ~ div, #replacedDoodle ~ canvas {display:none;}';
  35.  
  36. if (location.pathname.startsWith('/search')) addSt('.sfbg > *,.doodle>:not(.doodleFixed), header#kO001e a > img[src*="/logos/doodles/"], form[role="search"] img[src*="/logos/doodles/"] {display: none;} .logo.doodleFixed img{height:30px;width:92px;} .logo.doodlefixedParent {left:0; top:0; margin:0; padding:0; display: inline; position: unset;}');
  37. addSt('#hplogo > *:not(#replacedDoodle), a img#hplogo {display: none;}'+style);
  38.  
  39. if (document.readyState != 'loading') fix();
  40. else {
  41. document.addEventListener('DOMContentLoaded', function(){
  42. obs.disconnect();
  43. fix();
  44. });
  45.  
  46. const obs = new MutationObserver(function(muts){
  47. for (let mut of muts) {
  48. for (let n of mut.addedNodes) {
  49. if (n.classList && n.classList.contains('o3j99')) {
  50. if (n.querySelector('#hplogo')) {
  51. this.disconnect();
  52. fix();
  53. return;
  54. }
  55. }
  56. }
  57. }
  58. });
  59. obs.observe(document, { attributes: false, childList: true, subtree: true});
  60. }
  61.  
  62. function fix() {
  63. if (location.pathname.startsWith('/search')) {
  64. logo=document.querySelector('.logo.doodle');
  65. if (logo) ;
  66. else if (logo=document.querySelector('header#kO001e a > img[src*="/logos/doodles/"], form[role="search"] a > img[src*="/logos/doodles/"]')) logo=logo.parentNode;
  67. else if (logo=document.querySelector('.doodle > a')) ;
  68. else return;
  69. if (logo.parentNode.classList.contains('logo') ) logo.parentNode.classList.add('doodlefixedParent');
  70. logo.outerHTML='<div class="logo doodleFixed"><a href="/" id="logo"><img src="/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png"></a></div>';
  71. return;
  72. }
  73.  
  74. if ( (document.title!='Google') || fixed ) return;
  75. fixed=true;
  76. logo=document.querySelector('div#hplogo');
  77. if (!logo) {
  78. if (logo = document.querySelector(':scope a img#hplogo')) {
  79. logo=logo.closest('a');
  80. outer=true;
  81. }
  82. else if (logo = document.querySelector('img#hplogo')) {
  83. logo=logo.closest('picture') || logo.parentNode;
  84. outer=true;
  85. }
  86. }
  87. if (logo) {
  88. 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>';
  89. if (outer) logo.outerHTML=h;
  90. else logo.innerHTML=h;
  91. setTimeout(function(){
  92. var a=document.querySelectorAll('#replacedDoodle ~ :not(style)');
  93. a.forEach(function(e){ e.remove(); });
  94. }, 300);
  95. }
  96. else {
  97. st.remove();
  98. }
  99. }
  100.  
  101. })();