前往GreasyFork

吧啦吧啦

  1. // ==UserScript==
  2. // @name 前往GreasyFork
  3. // @namespace mimiko/greasyfork
  4. // @version 0.0.4
  5. // @description 吧啦吧啦
  6. // @author Mimiko
  7. // @license MIT
  8. // @include *
  9. // @grant GM.addStyle
  10. // ==/UserScript==
  11. // https://greasyfork.org/zh-CN/scripts/436753-%E5%89%8D%E5%BE%80greasyfork
  12. "use strict";
  13. (() => {
  14. if (window.top !== window.self) return;
  15. // function
  16. const insertHtml = () => {
  17. const $el = document.createElement("a");
  18. const href = `https://greasyfork.org/zh-CN/scripts/by-site/${window.location.host
  19. .split(".")
  20. .slice(-2)
  21. .join(".")}?filter_locale=0`;
  22. const listAttr = [
  23. ["href", href],
  24. ["id", "btn-jump-greasyfork"],
  25. ["rel", "noopener noreferrer"],
  26. ["target", "_blank"],
  27. ];
  28. listAttr.forEach((group) => $el.setAttribute(...group));
  29. document.body.appendChild($el);
  30. };
  31. const insertCss = () => {
  32. GM.addStyle(`
  33. #btn-jump-greasyfork {
  34. position: fixed;
  35. bottom: 0;
  36. left: 0;
  37. z-index: 65535;
  38. width: 32px;
  39. height: 32px;
  40. background-color: rgb(153, 0, 0);
  41. border-radius: 0 32px 0 0;
  42. cursor: pointer;
  43. transition: all 0.3s ease;
  44. opacity: 0;
  45. transform-origin: left bottom;
  46. transform: scale(0.5);
  47. }
  48. #btn-jump-greasyfork:hover {
  49. opacity: 1;
  50. transform: scale(1);
  51. }
  52. `);
  53. };
  54. const main = () => {
  55. insertCss();
  56. insertHtml();
  57. };
  58. // execute
  59. main();
  60. })();