Diskussionen » Greasy Fork Rückmeldungen

How to disallow to use the script if it is not the last version of it?

§
Veröffentlicht: 24.03.2023

I have some script for the specific game.
So, if game will updated then at best, script will break, and at worst, the player may be banned due to the implementation of new anti-cheat systems.
By the rules seems like I can only check for updates no lesser than one day, that means I can't do that on each site reloading.

NotYouMod
§
Veröffentlicht: 24.03.2023

There you go:

// ==UserScript==
// @name Your Userscript
// @namespace -
// @version 1.0.0
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant GM.info
// @grant GM.xmlhttpRequest
// ==/UserScript==

(function() {
  if(GM && GM.info) {
    const CURRENT_VERSION = GM.info.version
    const SCRIPT_PAGE = 'https://greasyfork.org/en/scripts/437291-open-source-alternative-redirector' // YOUR SCRIPT PAGE HERE
    const FETCH_URL = SCRIPT_PAGE + '.json'

    GM.xmlhttpRequest({
      method: 'GET',
      url: FETCH_URL,
      responseType: 'json',
      onload: function(res) {
        const RESPONSE = res.response
        const NOT_NEWEST_VERSION = RESPONSE.version !== CURRENT_VERSION

        if(NOT_NEWEST_VERSION) {
          const ERROR_MSG = 'Your script is too old! Please, update to newer version, here: ' + SCRIPT_PAGE

          throw new Error(ERROR_MSG)
        }
      }
    })
  } else {
    console.error('Cannot found GM.info object')
  }

  // Your code goes here...
})();

Don't forget to change SCRIPT_PAGE.

P.S. I didn't check the code, so if it didn't work out, I wouldn't be surprised

Attention, please. If the website's usage policy (or whatever copyright stuff) doesn't allow cheats, please, do not upload them on Greasy Fork, otherwise your user-script may be reported and then deleted.

§
Veröffentlicht: 24.03.2023

There you go:

// ==UserScript==
// @name Your Userscript
// @namespace -
// @version 1.0.0
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant GM.info
// @grant GM.xmlhttpRequest
// ==/UserScript==

(function() {
  if(GM && GM.info) {
    const CURRENT_VERSION = GM.info.version
    const SCRIPT_PAGE = 'https://greasyfork.org/en/scripts/437291-open-source-alternative-redirector' // YOUR SCRIPT PAGE HERE
    const FETCH_URL = SCRIPT_PAGE + '.json'

    GM.xmlhttpRequest({
      method: 'GET',
      url: FETCH_URL,
      responseType: 'json',
      onload: function(res) {
        const RESPONSE = res.response
        const NOT_NEWEST_VERSION = RESPONSE.version !== CURRENT_VERSION

        if(NOT_NEWEST_VERSION) {
          const ERROR_MSG = 'Your script is too old! Please, update to newer version, here: ' + SCRIPT_PAGE

          throw new Error(ERROR_MSG)
        }
      }
    })
  } else {
    console.error('Cannot found GM.info object')
  }

  // Your code goes here...
})();

Don't forget to change SCRIPT_PAGE.

P.S. I didn't check the code, so if it didn't work out, I wouldn't be surprised

Attention, please. If the website's usage policy (or whatever copyright stuff) doesn't allow cheats, please, do not upload them on Greasy Fork, otherwise your user-script may be reported and then deleted.

Well, thanks, I think? Because I already got something like this in my code, but the "Greasy fork rules > Code rules > code > 5" forbid to use such code because "Scripts must not check for updates at a rate higher than once per day. ...".

Also about

Attention, please. If the website's usage policy (or whatever copyright stuff) doesn't allow cheats, please, do not upload them on Greasy Fork, otherwise your user-script may be reported and then deleted.

I did find something in Terms of use, and it's only says that you account can be deleted if you do so.
Also that's just weird. Like, anyone can came in and say like "this open source code can do something that against our local policy" and will it work?

§
Veröffentlicht: 03.04.2023

Other websites' terms of service have no effect here on Greasy Fork. Those terms are between the website and the user of the website. The website may delete your account or whatever action is in the terms, but we're not gonna delete a script here because of that.

Copyright is a separate matter.

NotYouMod
§
Veröffentlicht: 03.04.2023
Bearbeitet: 03.04.2023

Yeah, both of you are right. Anyway, you can limit update checks too, there is how:

// ==UserScript==
// @name Your Userscript
// @namespace -
// @version 1.0.0
// @description try to take over the world!
// @author You
// @match *://*/*
// @grant GM.info
// @grant GM.xmlhttpRequest
// @grant GM.setValue
// @grant GM.getValue
// ==/UserScript==

(async function() {
  if(GM && GM.info) {
    const CURRENT_VERSION = GM.info.version
    const SCRIPT_PAGE = 'https://greasyfork.org/en/scripts/437291-open-source-alternative-redirector' // YOUR SCRIPT PAGE HERE
    const FETCH_URL = SCRIPT_PAGE + '.json'
    const ONE_DAY = 86400000
    let lastTimeChecked

    GM.getValue('last_time_checked').then(val =>
      if(!val) {
        const NOW = Date.now()

        await GM.setValue('last_time_checked', NOW)
        lastTimeChecked = NOW
      } else {
        lastTimeChecked = val
      }
    })

    if(Date.now() > lastTimeChecked + ONE_DAY) {
      GM.xmlhttpRequest({
        method: 'GET',
        url: FETCH_URL,
        responseType: 'json',
        onload: function(res) {
          const RESPONSE = res.response
          const NOT_NEWEST_VERSION = RESPONSE.version !== CURRENT_VERSION

          await GM.setValue('last_time_checked', Date.now())

          if(NOT_NEWEST_VERSION) {
            const ERROR_MSG = 'Your script is too old! Please, update to newer version, here: ' + SCRIPT_PAGE

            alert(ERROR_MSG)

            throw new Error(ERROR_MSG)
          }
        }
      })
    }
  } else {
    console.error('Cannot found GM.info object')
  }

  // Your code goes here...
})();

Antwort schreiben

Anmelden um eine Antwort zu senden.