Improved safe search

09/11/2025, 09:34:21

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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
        });
    });
}