Scripthub

Lots of scripts to enhance your browsing experience or automate tasks.

当前为 2024-08-24 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Scripthub
// @description Lots of scripts to enhance your browsing experience or automate tasks.
// @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)}`);
    }
  })();
}