Auto-Espande Google Search Tools

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

  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 26.2
  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://drive.google.com/*
  13. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  14. // @require http://code.jquery.com/jquery-latest.js
  15. // @require https://code.jquery.com/ui/1.13.2/jquery-ui.js
  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. // ==/UserScript==
  25. (function() {
  26. 'use strict';
  27. //scorrimento continuo pagine
  28. console.log('goo goo');
  29. window.onscroll = function() {
  30. var doc = document.documentElement;
  31. var current = doc.scrollTop + window.innerHeight;
  32. var height = doc.offsetHeight;
  33.  
  34. if (current === height) {
  35. console.log('In fondo alla pagina');
  36. var nextButton = document.getElementById('pnnext');
  37. if (nextButton) {
  38. nextButton.click();
  39. } else {
  40. console.log('Nessun pulsante per la pagina successiva trovato.');
  41. }
  42. }
  43. };
  44. ////////////////////
  45. miglioralo();
  46. function miglioralo() {
  47. if (document.readyState !== 'loading') {
  48. consent();
  49. } else {
  50. document.addEventListener('DOMContentLoaded', consent);
  51. }
  52. }
  53.  
  54. function consent() {
  55. var consentButton = document.querySelector('#introAgreeButton');
  56.  
  57. if (!consentButton) {
  58. consentButton = 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');
  59. }
  60.  
  61. if (!consentButton) {
  62. let otherButtons = document.querySelectorAll('div.lssxud button.nCP5yc:not(:disabled)');
  63. if (otherButtons.length > 1) {
  64. consentButton = otherButtons[1];
  65. }
  66. }
  67.  
  68. if (consentButton) {
  69. consentButton.click();
  70. }
  71. }
  72. //////////////////////////////////////////////////////////////////////
  73. // Funzione per cercare e cliccare sull'elemento tema scuro on
  74. function clickOnDarkTheme() {
  75. const elements = document.querySelectorAll('*');
  76. elements.forEach(element => {
  77. if (element.textContent.includes('Tema scuro: disattivato')) {
  78. element.click();
  79. }
  80. });
  81. }
  82.  
  83. // Esegui la funzione al caricamento della pagina
  84. window.addEventListener('load', clickOnDarkTheme);
  85. //////////////////////////////////////////////////////////////////////
  86. /////////////////////disattiva SafeSearch giugno 2024
  87. (function() {
  88. var url = new URL(window.location.href);
  89. var params = url.searchParams;
  90.  
  91. // Controlla se il parametro 'safe' è già impostato su 'off'
  92. if (params.get('safe') !== 'off') {
  93. params.set('safe', 'off');
  94. window.location.replace(url.toString());
  95. }
  96. /////////////////////////////////////////
  97. // Controlla se il parametro 'newwindows' è già impostato su '1'
  98. if (params.get('newwindow') !== '1') {
  99. params.set('newwindow', '1');
  100. window.location.replace(url.toString());
  101. }
  102. //30 risultati per pagina
  103. if (params.get('num') !== '30') {
  104. params.set('num', '30');
  105. window.location.replace(url.toString());
  106. }
  107. })();
  108. //////////////////////////
  109. //popup accedi a google (invasivo)settembre 2023
  110. GM_addStyle(".nD2EKb{display:none!important;}");
  111. //Filtro alcuni risultati potrebbero essere espliciti click automatico su ignora
  112. setTimeout(function(){document.querySelector("#appbar > div.zNFAfd > div > div.zRHtD > div.O6QT3d > div > div").click();},1000);//8marzo 2023
  113.  
  114. GM_addStyle("#result-stats{display:none!important;}");/* Circa 261.000.000 risultati (0,61 secondi) nascosto */
  115.  
  116. //pulsante Strumenti di ricerca rosso
  117. GM_addStyle("#hdtb-tls {color:red!important;background:green!important;border-radius:12px;border:2px solid red!important}");
  118. GM_addStyle("#hdtb-tls:hover{color:gold!important;}");
  119. //safesearch
  120. GM_addStyle(".F75bid {color:red!important;}");//link
  121. GM_addStyle(".F75bid:hover {color:gold!important;}");//al passaggio mouse
  122. GM_addStyle(".fFI3rb {background:green!important;border-radius:10px;border:2px solid red!important;}");//background
  123. //colore link immag notiz libri mappe
  124. GM_addStyle('.YmvwI{color:red!important; background:yellow!important;border-radius:8px;border:2px solid blue!important;}');
  125. GM_addStyle('.YmvwI:hover{color:green!important;}');
  126. GM_addStyle('.Lu57id{color:red!important; background:yellow!important;border-radius:8px;border:2px solid blue!important;}');//altro
  127. GM_addStyle('.Lu57id:hover{color:green!important;}');//altro al passaggio mouse
  128.  
  129. //////////////////////////////////////////////////////////
  130. GM_addStyle('.KTBKoe{color:red!important; background:yellow!important;border-radius:8px;border:px solid !important;}');//colori qualsiasi paese lingua data ecc
  131. GM_addStyle('.KTBKoe:hover{color:green!important;}');//al passaggio mouse
  132. GM_addStyle('.AozSsc{color:red!important; background:yellow!important;border-radius:8px;border:px solid !important;}');//cancella
  133. GM_addStyle('.AozSsc:hover{color:green!important;}');//cancella al pass mouse
  134.  
  135. //triangolini rossi
  136. GM_addStyle('.gTl8xb {border-color:red transparent!important}');
  137. //menu colorato
  138. GM_addStyle('.cF4V5c {color:lime!important;background:red !important;}');
  139. GM_addStyle('.cF4V5c {border:2px solid blue!important}');//bordo blu
  140. //no publicita correlate
  141. GM_addStyle('#rcnt .col:nth-of-type(3) {display:none !important;}');
  142. //Promemoria sulla privacy di Google
  143. GM_addStyle('#cnsh,#cnso,#cnsi{display:none!important}');
  144. //ricerche correlate
  145. GM_addStyle('#brs {display:none!important;}');
  146. GM_addStyle('.commercial-unit-desktop-top {display:none!important;}');
  147. //di nuovo publicita e correlati a destra
  148. GM_addStyle('#rhs {display:none!important;}');
  149. GM_addStyle('.YTDezd {display:none!important;}');
  150.  
  151. //////////////////////////////////////////////////aggiunto youtube
  152. // Trova gli elementi div e textarea di destinazione
  153. const targetDiv = document.querySelector('#hdtb-sc > div > div > div.crJ18e > div');
  154. const searchInput = document.querySelector('textarea.gLFyf');
  155.  
  156. // Create a button element
  157. const youtube = document.createElement('button');
  158. youtube.innerText = 'Youtube';
  159.  
  160. // Apply CSS styling to the button
  161. youtube.style.color = 'red';
  162. youtube.style.padding = '10px';
  163. youtube.style.background = 'yellow';
  164. youtube.style.border = '2px solid blue';
  165. youtube.style.borderRadius = '8px';
  166. youtube.style.cursor = 'pointer';
  167. youtube.style.padding = '5px';
  168. youtube.style.marginTop ='9px';
  169. youtube.href = 'https://www.youtube.com/results?search_query';
  170. // Aggiungi event listener per l'effetto al passaggio del mouse
  171. youtube.addEventListener('mouseover', function () {
  172. this.style.color = 'green';
  173. });
  174.  
  175. // Reimposta il colore quando il mouse se ne va
  176. youtube.addEventListener('mouseout', function () {
  177. this.style.color = 'red';
  178. });
  179. //Gestisci l'evento clic sul pulsante
  180. youtube.addEventListener('click', function() {
  181. // Ottieni la query di ricerca corrente dall'area di testo
  182. const searchQuery = searchInput.value.trim();
  183.  
  184. // Sostituisci gli spazi con '+'
  185. const modifiedQuery = searchQuery.replace(/ /g, '+');
  186.  
  187. // Create the YouTube search URL
  188. const youtubeURL = `https://www.youtube.com/results?search_query=${modifiedQuery}`;
  189.  
  190. // Open the YouTube URL in a new tab
  191. window.open(youtubeURL);
  192. });
  193.  
  194. // Append the button to the target div
  195. targetDiv.appendChild(youtube);
  196.  
  197. // Aggiungere un listener di eventi di scorrimento
  198. window.addEventListener('scroll', function() {
  199. // Controlla se l'utente si trova in cima alla pagina
  200. const isAtTop = window.pageYOffset === 0;
  201.  
  202. // Aggiorna il raggio del bordo del pulsante in base alla posizione di scorrimento
  203. youtube.style.borderRadius = isAtTop ? '24px' : '16px';
  204. });
  205.  
  206. // Set the URL as the tooltip when hovering over the button
  207. youtube.addEventListener('mouseenter', function() {
  208. const searchQuery = searchInput.value.trim();
  209. const modifiedQuery = searchQuery.replace(/ /g, '+');
  210. const youtubeURL = `https://www.youtube.com/results?search_query=${modifiedQuery}`;
  211. });
  212.  
  213. //Rimuovi il suggerimento quando non passi il mouse sopra il pulsante
  214. youtube.addEventListener('mouseleave', function() {
  215. youtube.removeAttribute('title');
  216. });
  217. ///////////////////////////////////
  218. (function() {
  219. 'use strict';
  220. ///////////////////// Mostra il menu Strumenti di ricerca
  221. const interval = setInterval(() =>
  222. {var toolsButton = document.getElementById('hdtb-tls');
  223. if (toolsButton.getAttribute("aria-expanded") === "true") {
  224.  
  225. clearInterval(interval);
  226. }
  227. else{toolsButton.click();
  228. }
  229. }, 250);
  230. ///////////////////////////////////////////
  231. // Funzione per inizializzare la finestra
  232. function initializeWindow() {
  233. // Crea la finestra e aggiunge il contenuto
  234. var $ = window.jQuery;
  235. $('body').append(`
  236. <div id="googleok" style="position:fixed;top:5px;left:850px;width:430px;height:auto;z-index:9999;color:lime;">
  237. <fieldset style="background-color:#3b3b3b;border:2px solid red;border-radius:5px;">
  238. <legend style="text-align:center;color:lime;">Clock</legend>
  239. <div style="display: flex; align-items: center;">
  240. <div id="datePickerx" title="Data-ora" style="border:1px solid yellow;border-radius:5px;cursor:pointer;">
  241. </div>
  242. <div>
  243. <label title="Cambia lingua data" style="color:lime;display:inline-flex;cursor:pointer">
  244. <input type="radio" name="options" title="Cambia lingua data" value="changeLanguage" style="cursor:pointer;">Lingua
  245. </label>
  246. <label title="Cambia 12/24h" style="color:lime;display:inline-flex;cursor:pointer">
  247. <input type="radio" name="options" title="Cambia 12/24h" value="toggleFormat" style="cursor:pointer;">12/24h
  248. </label>
  249. <span class="chiudi" title="Chiudi" id="close" style="background-color:red;color:lime;border:1px solid yellow;border-radius:50%;cursor:pointer;font-size:14px;padding:3px 6px;margin-left:4px;">X</span>
  250.  
  251. </div>
  252. </div>
  253. </fieldset>
  254. </div>
  255. `);
  256.  
  257. // Event listener for radio button selection
  258. $('input[name="options"]').on('change', function() {
  259. const selectedValue = $(this).val();
  260. if (selectedValue === 'changeLanguage') {
  261. changeLanguage();
  262. } else if (selectedValue === 'toggleFormat') {
  263. toggleFormat();
  264. }
  265.  
  266. // Disable the radio buttons temporarily
  267. $('input[name="options"]').prop('disabled', true);
  268.  
  269. // Re-enable the radio buttons after a short delay
  270. setTimeout(() => {
  271. $('input[name="options"]').prop('disabled', false).prop('checked', false);
  272. }, 300); // Milliseconds
  273. });
  274.  
  275. // Imposta la posizione iniziale della finestra
  276. let windowPosition = {
  277. x: 50,
  278. y: 50
  279. };
  280.  
  281. // Carica la posizione salvata precedentemente, se disponibile
  282. if (GM_getValue('userscript_window_position')) {
  283. windowPosition = JSON.parse(GM_getValue('userscript_window_position'));
  284. $('#googleok').css({top: windowPosition.y, left: windowPosition.x});
  285. }
  286.  
  287. // Funzione per salvare la posizione della finestra
  288. function saveWindowPosition() {
  289. const position = $('#googleok').position();
  290. GM_setValue('userscript_window_position', JSON.stringify({x: position.left, y: position.top}));
  291. }
  292.  
  293. let use12HourFormat = GM_getValue('use12HourFormat', true); // Default è il formato 24 ore true
  294. let language = GM_getValue('language') || 'it'; // Recupera la lingua dal localStorage o usa 'it' come predefinita
  295.  
  296. const languages = {
  297. en: { weekday: 'short', month: 'short', day: '2-digit', year: 'numeric' },
  298. it: { weekday: 'short', month: '2-digit', day: '2-digit', year: 'numeric' }
  299. };
  300.  
  301. // Funzione per aggiornare l'ora
  302. function updateClock() {
  303. const now = new Date();
  304. let hours = now.getHours();
  305. const minutes = String(now.getMinutes()).padStart(2, "0");
  306. const seconds = String(now.getSeconds()).padStart(2, "0");
  307. const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
  308. const date = now.toLocaleString(language, languages[language]); // Usa la lingua selezionata per la data
  309. let period = "";
  310.  
  311. if (use12HourFormat) { // Condizione corretta per il formato 12 ore
  312. period = hours >= 12 ? " PM" : " AM";
  313. hours = hours % 12 || 12; // Converte in formato 12 ore
  314. }
  315.  
  316. hours = String(hours).padStart(2, "0"); // Aggiunge lo zero iniziale per ore
  317. document.querySelector('#datePickerx').textContent = `${date} ${hours}:${minutes}:${seconds}:${milliseconds}${period}`;
  318. }
  319.  
  320. function changeLanguage() {
  321. language = (language === 'it') ? 'en' : 'it'; // Alterna tra 'it' e 'en'
  322. GM_setValue('language', language); // Salva la lingua scelta
  323. }
  324.  
  325. function toggleFormat() {
  326. use12HourFormat = !use12HourFormat; // Alterna il formato orario
  327. GM_setValue('use12HourFormat', use12HourFormat); // Salva lo stato del formato
  328. }
  329. // Chiama la funzione di inizializzazione e avvia il timer
  330. const intervalTime = 90; // Imposta l'intervallo di tempo
  331. setInterval(updateClock, intervalTime);
  332. // Chiudi la finestra quando il pulsante di chiusura viene cliccato
  333. var Close=document.querySelector('#close');
  334. Close.addEventListener('click',provag,false);
  335. // Nascondi o mostra la finestra dal menu
  336. function provag() {
  337. var box = document.getElementById('googleok');
  338. box.style.display = ((box.style.display!='none') ? 'none' : 'block');
  339. }
  340. GM_registerMenuCommand("nascondi/mostra time",provag);
  341.  
  342. // Rendi la finestra trascinabile
  343. $('#googleok').draggable({
  344. containment: 'window',
  345. stop: saveWindowPosition
  346. });
  347. }
  348. // Chiama la funzione di inizializzazione della finestra
  349. initializeWindow();
  350. })();
  351. })();