Auto-Espande Google Search Tools

Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google

目前为 2024-03-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Auto-Espande Google Search Tools
  3. // @description Mostra il menu Strumenti di ricerca nei risultati di ricerca di Google
  4. // @namespace https://greasyfork.org/users/237458
  5. // @author figuccio
  6. // @version 21.5
  7. // @match https://*.google.com/*
  8. // @match https://*.google.it/*
  9. // @match https://*.google.fr/*
  10. // @match https://*.google.es/*
  11. // @match https://*.google.de/*
  12. // @exclude https://translate.google.it/?hl=it
  13. // @exclude https://drive.google.com/*
  14. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  15. // @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=19641
  16. // @grant GM_addStyle
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @run-at document-start
  20. // @icon https://www.google.com/favicon.ico
  21. // @noframes
  22. // @license MIT
  23. // @grant GM_registerMenuCommand
  24. // @require http://code.jquery.com/jquery-latest.js
  25. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
  26. // ==/UserScript==
  27. (function() {
  28. 'use strict';
  29. var $ = window.jQuery;
  30. if (document.readyState != 'loading') consent();
  31. else document.addEventListener('DOMContentLoaded', consent);
  32.  
  33. function consent() {
  34. var e=document.querySelector('#introAgreeButton');
  35. if (!e) e=document.querySelector('div.jw8mI button#zV9nZe.tHlp8d, div.VDity button#L2AGLb.tHlp8d, div.GzLjMd button#L2AGLb.tHlp8d, form[action="https://consent.google.com/s"] button');
  36. if (!e) {
  37. let A=document.querySelectorAll('div.lssxud button.nCP5yc:not(:disabled)');
  38. if (A.length > 1) e=A[1];
  39. }
  40. e && e.click();
  41. }
  42.  
  43. /////////////////////////////////////
  44. window.addEventListener("load",function(){
  45. disableSafesearch();
  46. addClockFieldset();
  47. makeClockDraggable();
  48. });// Aggiungi un fieldset per l'orologio
  49. function addClockFieldset() {
  50. var fieldset = document.createElement('fieldset');
  51. fieldset.setAttribute('id', 'clockFieldset');
  52. fieldset.style.position = 'fixed'; // Usa 'fixed' invece di 'absolute'
  53. fieldset.style.top = '5px'; // Posizione iniziale
  54. fieldset.style.left = '850px'; // Posizione iniziale
  55. fieldset.style.zIndex = '99999'; // Imposta un indice z elevato per assicurarti che sia sopra agli altri elementi
  56. fieldset.style.background = '#3b3b3b';
  57. fieldset.style.color = 'lime';
  58. fieldset.style.padding = '10px';
  59. fieldset.style.border = '1px solid red';
  60. fieldset.style.borderRadius = '5px';
  61. fieldset.style.width='280px';
  62. fieldset.style.display='flex';
  63.  
  64. //Aggiunto un div vuoto per lo spazio tra lorologio e il menu
  65. fieldset.innerHTML = '<legend style="text-align:center;">Data-Time <span id="closeClock" style="cursor:pointer;color:red;background:orange;border:1px solid lime;border-radius:30px;padding:3px 6px;">x</span></legend><div id="clock"></div><div style="width:10px;"></div>'; // Aggiunto un div vuoto per lo spazio
  66. ///////////////////////////
  67.  
  68. var selectMenu = document.createElement('select');
  69. selectMenu.innerHTML ='<option value="#">Scegli ...</option>'+
  70. '<option style="background-color:Green" title="Vai su facebook" value="https://www.facebook.com/">Facebook</option>' +
  71. '<option style="background-color:Brown" title="Vai su youtube" value="https://www.youtube.com/">Youtube</option>' +
  72. '<option style="background-color:Red" title="Vedi altri script" value="https://greasyfork.org/it/users/237458-figuccio">Autore</option>';
  73.  
  74. selectMenu.addEventListener('change', function() {
  75. var selectedOption = this.options[this.selectedIndex];
  76. //location.href = selectedOption.value;//apre nella stessa scheda
  77. window.open(selectedOption.value, '_blank');//apre in una nuova scheda
  78. });
  79.  
  80. fieldset.appendChild(selectMenu);
  81. // Aggiungi questo codice dopo la creazione del menu select
  82. selectMenu.style.background = '#3b3b3b';
  83. selectMenu.style.color = 'lime';
  84. selectMenu.style.border = '1px solid yellow';
  85. selectMenu.style.borderRadius = '5px';
  86. selectMenu.style.cursor = 'pointer';
  87.  
  88.  
  89.  
  90.  
  91. ////////////////////
  92. document.body.appendChild(fieldset);
  93. updateClock();
  94. setInterval(updateClock, 70); // Aggiorna l'orologio ogni 100 millisecondi
  95. /////////////////
  96. // Gestore di eventi per nascondere l'elemento quando l'icona viene cliccata
  97. document.getElementById('closeClock').addEventListener('click', function() {
  98. fieldset.style.visibility = 'hidden';//funziona impedisce che il menu cambi la posizione se mostrato nascosto
  99. });
  100. }
  101.  
  102. //////////////////////////
  103. // Aggiorna l'orologio
  104. function updateClock() {
  105. var d = new Date();
  106. var tem = d.toLocaleTimeString();
  107. var mm = d.getMilliseconds();//millisecondi settembre 2023
  108. ////////////////short long
  109. var date = new Date().toLocaleString('it', {'weekday': 'short', 'month': '2-digit', 'day': '2-digit','year':'numeric'});
  110. document.getElementById('clock').innerHTML =date +" "+ tem +":"+ mm;
  111. //////////////////////////
  112. // Aggiunta del bordo e del bordo arrotondato
  113. var clockElement = document.getElementById('clock');
  114. clockElement.style.border = '1px solid lime';
  115. clockElement.style.borderRadius = '7px';
  116. clockElement.style.color = '';
  117. clockElement.style.cursor = 'pointer';
  118. /////////////////////
  119. }
  120.  
  121. // Rendi il fieldset dragabile
  122. function makeClockDraggable() {
  123. $('#clockFieldset').draggable({
  124. containment: 'window',
  125. stop: function(event, ui) {
  126. var position = ui.position;
  127. GM_setValue('clockPosition', JSON.stringify(position)); // Salva la posizione
  128. }
  129. });
  130.  
  131. // Ripristina la posizione memorizzata
  132. var storedPosition = GM_getValue('clockPosition');
  133. if (storedPosition) {
  134. var position = JSON.parse(storedPosition);
  135. $('#clockFieldset').css({ top: position.top + 'px', left: position.left + 'px' });
  136. }
  137. }
  138.  
  139. //disable safesearch
  140. function disableSafesearch() {
  141. var safeui = document.querySelector("a[aria-label][href*='setprefs?sig']");
  142. if(safeui != null){
  143. if(safeui.href.match(/safeui=off$/) == null){
  144. window.location = safeui.href.replace(/safeui=(on|images)$/,"safeui=off");
  145. console.log("Google disable safesearch: done!");
  146. } else {
  147. console.log("Google disable safesearch: nothing to do!");
  148. }
  149. } else {
  150. safeui = document.querySelector("a[href*='setprefs?sig'][href$='safeui=off']");
  151. if(safeui != null) {
  152. window.location = safeui.href;
  153. console.log("Google disable safesearch: done!");
  154. } else {
  155. if(document.querySelector("a[href*='setprefs?sig'][href$='safeui=on']") != null){
  156. console.log("Google disable safesearch: nothing to do!");
  157. } else {
  158. console.log("Google disable safesearch: failed!");
  159. }
  160. }
  161. }
  162. }
  163. })();
  164. /////////////////////////////////////////////////////////////////////////
  165. //popup accedi a google (invasivo)settembre 2023
  166. GM_addStyle(".nD2EKb{display:none!important;}");
  167. //Filtro alcuni risultati potrebbero essere espliciti click automatico su ignora
  168. setTimeout(function(){document.querySelector("#appbar > div.zNFAfd > div > div.zRHtD > div.O6QT3d > div > div").click();},1000);//8marzo 2023
  169. // Show the Search Tools menu
  170. GM_addStyle("#hdtbMenus{display:block !important;position:absolute !important;top:8px !important;right:500px!important;}");//giugno 2023 riposizionato
  171. GM_addStyle("#result-stats{display:none!important;}");/* Circa 261.000.000 risultati (0,61 secondi) nascosto */
  172.  
  173. //pulsante Strumenti di ricerca rosso
  174. GM_addStyle("#hdtb-tls {color:red!important;background:green!important;border-radius:12px;border:2px solid red!important}");
  175. GM_addStyle("#hdtb-tls:hover{color:gold!important;}");
  176. //pulsante tutti i filtri
  177. GM_addStyle(".fKmH1e {color:red!important;background:green!important;border-radius:12px;border:2px solid red!important;height:36px;}");//pulsante tutti i filtri
  178. GM_addStyle(".fKmH1e:hover{color:gold!important;}");
  179. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  180. //safesearch
  181. GM_addStyle(".F75bid {color:red!important;}");//link
  182. GM_addStyle(".F75bid:hover {color:gold!important;}");//al passaggio mouse
  183. GM_addStyle(".fFI3rb {background:green!important;border-radius:10px;border:2px solid red!important;}");//background
  184. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  185. GM_addStyle('.IUOThf{background-color:#303134!important;width:723px;border-radius:12px;border:2px solid red!important}');
  186. //colore link immag notiz libri mappe
  187. GM_addStyle('.GKS7s .FMKtTb, .GKS7s .RWhoyd.mol54e{color:red!important;}');
  188. //al passaggio mouse link
  189. GM_addStyle('.GKS7s :hover {color:green!important;}');
  190. GM_addStyle('.GKS7s{background:gold!important;border:2px solid blue!important;}');
  191. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  192. //colori testo strumenti colore verde Search Tools (qualsiasi paese-lingua -data-tutti i risultati)
  193. GM_addStyle('.hdtb-mn-hd {color:green!important;background:gold!important;border-radius:9px;border:2px solid blue!important}');
  194. //link espansione strumenti colore verde che diventa rosso al passaggio mouse
  195. GM_addStyle('.hdtb-mn-hd:hover {color:red!important}');
  196. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  197. //topbar espansioni strumenti colorata Search Tools
  198. GM_addStyle('.WE0UJf {background:#303134!important;width:700px;border-radius:12px;border:1px solid red!important}');//ok
  199. //pulsante tutti
  200. GM_addStyle('#hdtb-msb .hdtb-mitem.hdtb-msel{color:red!important;background:orange!important;border-radius:8px;border:2px solid green!important;padding:4px 4px;border-bottom:6px solid blue!important}');
  201. //triangolini rossi
  202. GM_addStyle('.gTl8xb {border-color:red transparent!important}');
  203. //menu colorato
  204. GM_addStyle('.cF4V5c {color:lime!important;background:red !important;}');
  205. GM_addStyle('.cF4V5c {border:2px solid blue!important}');//bordo blu
  206.  
  207. //no publicita correlate
  208. GM_addStyle('#rcnt .col:nth-of-type(3) {display:none !important;}');
  209.  
  210. //le persone anno chiesto anche
  211. GM_addStyle('.OJXvsb.Wnoohf.cUnQKe.kp-blk {display:none !important;}');
  212.  
  213. //Promemoria sulla privacy di Google
  214. GM_addStyle('#cnsh,#cnso,#cnsi{display:none!important}');
  215. //////////////////////////////////////////////////aggiunto youtube
  216. process();
  217. new MutationObserver(process).observe(document.body || document.documentElement, { childList: true, subtree: true });
  218.  
  219. function process(mutations) {
  220. let q,
  221. queryElement = document.querySelector('input[name="q"]');// selector for the Google search input textbox
  222.  
  223. if (queryElement?.value) q = encodeURIComponent(queryElement.value);
  224. else if (q = location.href.match(/^.+?(?:[#/&?](?:q|query))=(.+?)(?:|&.+|\|.+)$/)) q = q[1];
  225.  
  226. let link = document.querySelector(`a[href*='tbm=vid']`);
  227.  
  228. if (q && link?.href) {
  229. link.href = 'https://www.youtube.com/results?search_query=' + q;
  230. link.textContent = 'YouTube';
  231. console.log('create', link.textContent);
  232. }
  233. }
  234. ///ricerche correlate
  235. GM_addStyle('#brs {display:none !important;}');
  236. GM_addStyle('.commercial-unit-desktop-top {display:none !important;}');
  237.  
  238. ////////////////////////////////
  239. //di nuovo publicita e correlati a destra
  240. GM_addStyle('#rhs {display:none!important;}');
  241. GM_addStyle('.YTDezd {display:none!important;}');
  242. /////////////////////////////////////////////////
  243. (function() {
  244. 'use strict';
  245. if (GM_getValue('Open in new window?') === undefined)
  246. { //Avvia la condizione if
  247.  
  248. GM_setValue('Open in new window?', 1); //Imposta lo script per aprire i siti Web in una nuova scheda 1 apre 0 no
  249. } //Termina la condizione if
  250.  
  251. if (location.pathname === '/search' && location.href.match('&newwindow=' + GM_getValue('Open in new window?')) === null) //If the current search doesn't have the user choices applied
  252. { //Avvia la condizione if
  253. location.href = location.href += '&newwindow=' + GM_getValue('Open in new window?'); //Reindirizza per aggiungere le scelte dell'utente
  254. } //Termina la condizione if
  255.  
  256. /////////////////
  257. //mostra/nascondi box
  258. function provag() {
  259. var box = document.getElementById('clockFieldset');
  260. box.style.visibility = (box.style.visibility !== 'hidden') ? 'hidden' : 'visible';
  261. }
  262. GM_registerMenuCommand("nascondi/mostra time", provag);
  263.  
  264. })();
  265.  
  266.  
  267.