Improved safe search

09/11/2025, 09:34:21

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Improved safe search
// @namespace   Violentmonkey Scripts
// @match       https://www.google.com/search*
// @grant       none
// @version     1.0
// @author      SHA
// @license     GNU GPLv3
// @description 09/11/2025, 09:34:21
// ==/UserScript==

window.addEventListener("load", async (event) => {
//  const wordList = ["ok1", "test2"];
//  const searchInput = await waitForElement('#APjFqb');
//  console.log(searchInput);
//  const didYouMean = await waitForElement('#oFNiHe a[href^="/search?"]');
//  console.log(didYouMean);

if (document.querySelector('[data-notice="SAFESEARCH_LOCKED"]')) {
  console.log('found')
  const searchInput = document.getElementById('APjFqb');
  history.replaceState(null, null, "q");
  document.querySelector("[jsname=pkjasb]").click();
  document.querySelector("title").innerHTML = "Quote";
  document.body.click();
  document.getElementById('main').innerHTML = `
   <iframe src="https://www.nodi.so/widgets/embed/public/quotes" style="margin: auto; display: block; width: 500px; height: 300px"></iframe>
  `;
}
});

function waitForElement(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }
        const observer = new MutationObserver(mutations => {
            const element = document.querySelector(selector);
            console.log('performed querey selection');
            if (element) {
                observer.disconnect();
                resolve(element);
            }
        });
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}