Furaffinity-Match-List

Library to create a matchlist for your Furaffinity Script

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greatest.deepsurf.us/scripts/485827/1549457/Furaffinity-Match-List.js

  1. // ==UserScript==
  2. // @name Furaffinity-Match-List
  3. // @namespace Violentmonkey Scripts
  4. // @grant GM_info
  5. // @version 1.1.2
  6. // @author Midori Dragon
  7. // @description Library to create a matchlist for your Furaffinity Script
  8. // @icon https://www.furaffinity.net/themes/beta/img/banners/fa_logo.png
  9. // @license MIT
  10. // @homepageURL https://greatest.deepsurf.us/scripts/485827-furaffinity-match-list
  11. // @supportURL https://greatest.deepsurf.us/scripts/485827-furaffinity-match-list/feedback
  12. // ==/UserScript==
  13. // jshint esversion: 8
  14. (() => {
  15. "use strict";
  16. class GMInfo {
  17. static isBrowserEnvironment() {
  18. return "undefined" != typeof browser && void 0 !== browser.runtime || "undefined" != typeof chrome && void 0 !== chrome.runtime;
  19. }
  20. static getBrowserAPI() {
  21. if ("undefined" != typeof GM_info && null != GM_info) return GM_info; else if ("undefined" != typeof browser && void 0 !== browser.runtime) return browser; else if ("undefined" != typeof chrome && void 0 !== chrome.runtime) return chrome; else throw new Error("Unsupported browser for SyncedStorage.");
  22. }
  23. static get scriptName() {
  24. if (GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().runtime.getManifest().name; else return GMInfo.getBrowserAPI().script.name;
  25. }
  26. static get scriptVersion() {
  27. if (GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().runtime.getManifest().version; else return GMInfo.getBrowserAPI().script.version;
  28. }
  29. static get scriptDescription() {
  30. if (GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().runtime.getManifest().description; else return GMInfo.getBrowserAPI().script.description;
  31. }
  32. static get scriptAuthor() {
  33. if (GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().runtime.getManifest().author; else return GMInfo.getBrowserAPI().script.author;
  34. }
  35. static get scriptNamespace() {
  36. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().script.namespace;
  37. }
  38. static get scriptSource() {
  39. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().script.source;
  40. }
  41. static get scriptIcon() {
  42. if (GMInfo.isBrowserEnvironment()) {
  43. const manifest = GMInfo.getBrowserAPI().runtime.getManifest();
  44. let largestIcon = 0;
  45. for (const key of Object.keys(manifest.icons)) {
  46. const size = parseInt(key);
  47. if (size > largestIcon) largestIcon = size;
  48. }
  49. return manifest.icons[largestIcon.toString()];
  50. } else return GMInfo.getBrowserAPI().script.icon;
  51. }
  52. static get scriptIcon64() {
  53. if (GMInfo.isBrowserEnvironment()) {
  54. const manifest = GMInfo.getBrowserAPI().runtime.getManifest();
  55. return null == manifest.icons ? void 0 : manifest.icons[64];
  56. } else return GMInfo.getBrowserAPI().script.icon64;
  57. }
  58. static get scriptAntifeature() {
  59. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().script.antifeature;
  60. }
  61. static get scriptOptions() {
  62. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().script.options;
  63. }
  64. static get scriptMetaStr() {
  65. if (GMInfo.isBrowserEnvironment()) return JSON.stringify(GMInfo.getBrowserAPI().runtime.getManifest()); else return GMInfo.getBrowserAPI().scriptMetaStr;
  66. }
  67. static get scriptHandler() {
  68. if (GMInfo.isBrowserEnvironment()) return "undefined" != typeof browser ? "Firefox" : "Chrome"; else return GMInfo.getBrowserAPI().scriptHandler;
  69. }
  70. static get scriptUpdateURL() {
  71. if (GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().runtime.getManifest().update_url; else return GMInfo.getBrowserAPI().scriptUpdateURL;
  72. }
  73. static get scriptWillUpdate() {
  74. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().scriptWillUpdate;
  75. }
  76. static get scriptResources() {
  77. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().scriptResources;
  78. }
  79. static get downloadMode() {
  80. if (!GMInfo.isBrowserEnvironment()) return GMInfo.getBrowserAPI().downloadMode;
  81. }
  82. }
  83. class MatchList {
  84. get hasMatch() {
  85. var _a;
  86. if (!this.runInIFrame && this.isWindowIFrame) return false;
  87. if (!this.matches.some((x => window.location.toString().includes(x)))) return false;
  88. let color = "color: blue";
  89. if (null === (_a = window.matchMedia) || void 0 === _a ? void 0 : _a.call(window, "(prefers-color-scheme: dark)").matches) color = "color: aqua";
  90. let runString = this.logRunning ? `${GMInfo.scriptName} v${GMInfo.scriptVersion}` : "", run = true;
  91. if (window.location.toString().includes("settings?extension")) {
  92. runString = `Settings: ${GMInfo.scriptName} v${GMInfo.scriptVersion}`;
  93. run = false;
  94. } else if (null != this.customSettings) runString = `${this.customSettings.headerName}: ${this.customSettings.toString()}`; else runString = `Running: ${GMInfo.scriptName} v${GMInfo.scriptVersion}`;
  95. if (this.logRunning) console.info(`%c${runString}`, color);
  96. return run;
  97. }
  98. get match() {
  99. if (this.runInIFrame || window.parent === window) return this.matches.find((x => window.location.toString().includes(x)));
  100. }
  101. get isWindowIFrame() {
  102. return window !== window.parent;
  103. }
  104. constructor(customSettings) {
  105. this.matches = [];
  106. this.runInIFrame = false;
  107. this.logRunning = true;
  108. this.customSettings = customSettings;
  109. }
  110. addMatch(match) {
  111. this.matches.push(match);
  112. }
  113. removeMatch(match) {
  114. this.matches = this.matches.filter((m => m !== match));
  115. }
  116. }
  117. Object.defineProperties(window, {
  118. FAMatchList: {
  119. get: () => MatchList
  120. }
  121. });
  122. })();