議論 » Greasy Fork への意見

How Greasy Fork's script button being dynamic?

      <div id="install-area">
          <a class="install-link" data-install-format="js" data-ping-url="/scripts/468495/install-ping?authenticity_token=xxxxxxx" data-ip-address="xxxxxx" data-script-id="468495" data-ping-key="xxxxx" data-is-previous-version="false" data-previous-version-warning="This is not the latest version of this script. If you install it, you will never be updated to a newer version. Install anyway?" rel="nofollow" data-script-name="GreasyFork Search" data-script-namespace="http://tampermonkey.net/" data-script-version="0.4.4" data-update-label="Update to version 0.4.4" data-downgrade-label="Downgrade to version 0.4.4" data-reinstall-label="Reinstall version 0.4.4" href="/scripts/468495-greasyfork-search/code/GreasyFork%20Search.user.js">Install this script</a><a class="install-help-link" title="How to install" rel="nofollow" href="/en/help/installing-user-scripts">?</a>
      </div>

How this works? Might I ask how to interact with the UserScript manager in Greasy Fork?

I am thinking to write a UserScript to detect whether a script is installed or not in the search list page.

§
投稿日: 2023/07/29
編集日: 2023/07/29

install.js https://pastebin.com/27DneanG

micromodal.js https://pastebin.com/yAhuhSws

I think this part
import { canInstallUserJS, canInstallUserCSS } from "./managers";
is the most important one
managers.js https://pastebin.com/WMJiBddk

§
投稿日: 2023/07/30
編集日: 2023/07/30

install.js https://pastebin.com/27DneanG

micromodal.js https://pastebin.com/yAhuhSws

I think this part
import { canInstallUserJS, canInstallUserCSS } from "./managers";
is the most important one
managers.js https://pastebin.com/WMJiBddk

Thanks!!! I found that how it works.

window.external.Violentmonkey OR window.external.Tampermonkey is an object with string version and function isInstalled.

isInstalled requires two string parameters (name and namespace) and return a Promise.

window.external.Violentmonkey.isInstalled("YouTube CPU Tamer by AnimationFrame","http://tampermonkey.net/").then(r=>console.log(r))

It will give the version code of the installed script, or null if not installed.

§
投稿日: 2023/07/30
編集日: 2023/07/30

@CY Fung

Please give me the shortest possible code to achieve that, I will love to see it working in a simple way, and in a single script. I was too lazy to read everything, understand it, then code it. But I am very interested in your project!

返信を投稿

返信を投稿するにはログインしてください。