GreasyFork Script Finder

获取当前页面的主域名并打开 GreasyFork 查找脚本

当前为 2025-03-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GreasyFork Script Finder
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 获取当前页面的主域名并打开 GreasyFork 查找脚本
  6. // @author Felix
  7. // @license Felix
  8. // @match *://*/*
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_openInTab
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 注册(不可用)菜单命令
  17. GM_registerMenuCommand("查找该域名的GreasyFork脚本", function() {
  18. // 获取当前页面的完整域名
  19. const domain = window.location.hostname;
  20.  
  21. // 使用正则表达式提取主域名
  22. const mainDomain = domain.replace(/^.*\.(?:com|org|net|gov|edu|io|co|info|me|tv)(?:\.[a-z]{2,})?$/, "$&").split('.').slice(-2).join('.');
  23.  
  24. // 生成 GreasyFork 搜索链接
  25. const url = `https://gf.qytechs.cn/zh-CN/scripts/by-site/${mainDomain}`;
  26.  
  27. // 在新标签页中打开该链接
  28. GM_openInTab(url, { active: true });
  29. });
  30. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址