Scripthub

Lots of userscripts by pooiod7

Od 24.08.2024.. Pogledajte najnovija verzija.

// ==UserScript==
// @name        Scripthub
// @description Lots of userscripts by pooiod7
// @namespace   https://userscripts.org
// @include     *
// @version     1
// @license     GNU GPLv3
// ==/UserScript==

// go to https://userscripts.org/ after installing (or press "ctrl + q" 2 times)
if (window.location.hostname === 'userscripts.org') {
  var scr = "https://pooiod7.neocities.org/projects/scripthub/pages" + (window.location.pathname=="/"?"/home":window.location.pathname) + ".js";

  var script = document.createElement('script');
  script.src = scr;
  document.body.append(script);
} else {
  (function() {
    const urlParams = new URLSearchParams(window.location.search);
    const userscripts = urlParams.get('userscripts');

    if (new URLSearchParams(window.location.search).get('noscripts')) {
      document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.key === 'q') {
          event.preventDefault();
          const url = new URL(window.location);
          url.searchParams.delete('noscripts');
          window.location.href = url.toString();
        }
      });
      return;
    }

    if (userscripts) {
        try {
          const scriptUrls = JSON.parse(userscripts);
          scriptUrls.forEach(url => {
              const script = document.createElement('script');
              script.src = url;
              document.body.appendChild(script);
          });

          let ctrlQPressed = false;

          document.addEventListener('keydown', function(event) {
            if (event.ctrlKey && event.key === 'q') {
              event.preventDefault();
              if (ctrlQPressed) {
                window.location.href = 'https://userscripts.org/';
              } else {
                ctrlQPressed = true;
                setTimeout(() => {
                  const url = new URL(window.location);
                  url.searchParams.set('noscripts', 'true');
                  window.location.href = url.toString();
                }, 300);
              }
            } else {
              ctrlQPressed = false;
            }
          });

          urlParams.delete('userscripts');
          const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
          history.replaceState(null, '', newUrl);
        } catch (e) {
          console.error('Error parsing userscripts:', e);
        }
    } else {
      const currentSite = window.location.href;
      window.location.replace(`https://userscripts.org/?tosite=${encodeURIComponent(currentSite)}`);
    }
  })();
}