跳转github1s 、 sandbox

跳转github1s 、 sandbox 连接

  1. // ==UserScript==
  2. // @name 跳转github1s 、 sandbox
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 跳转github1s 、 sandbox 连接
  6. // @author 刘士朋
  7. // @match https://github.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12. let config;
  13. (function () {
  14. "use strict";
  15. config = document.createElement("div");
  16. config.className = "aaa";
  17. document.body.appendChild(config);
  18. let paths = ["1s", "box"];
  19.  
  20. paths.forEach((path) => {
  21. createStopBtn(path, () => {
  22. window.open(window.location.href.replace("github", (str) => {
  23. return str + path;
  24. }));
  25. });
  26. });
  27. })();
  28.  
  29. function createStopBtn(str, fn) {
  30. // 创建容器元素
  31. const container = document.createElement("div");
  32. container.className = "containerLiu";
  33. container.addEventListener("click", () => {
  34. fn?.();
  35. });
  36.  
  37. // 创建按钮元素
  38. const button = document.createElement("button");
  39. button.className = "button";
  40. button.textContent = str ?? "stop";
  41.  
  42. // 将按钮添加到容器中
  43. container.appendChild(button);
  44.  
  45. const style = document.createElement("style");
  46. const theHead = document.head || document.getElementsByTagName("head")[0];
  47. style.appendChild(
  48. document.createTextNode(
  49. `.aaa{display:flex;gap:40px;position:fixed;right:12%;top:225px;z-index:999;flex-direction:column;}.containerLiu{font-size:12px;width:46px;height:42px;background-color:#644dff;overflow:hidden;border-radius:100%;display:flex;justify-content:center;align-items:center;transform:scale(1.5) translateX(-25%);box-shadow:0 8px 2px #4836bb;transition:all .1s ease;filter:drop-shadow(0 6px 2px rgba(72,54,187,0.22));border:1px solid #4836bb}.button{padding:0; cursor:pointer;position:absolute;height:110%;width:110%;background-color:#644dff;color:white}.container:has(.button:active){box-shadow:none;margin-top:32px;filter:drop-shadow(0 3px 1px rgba(72,54,187,0.75))}`
  50. )
  51. );
  52. theHead.appendChild(style);
  53.  
  54. // 将容器添加到文档中的适当位置
  55. config.appendChild(container);
  56. }