Discussions » Greasy Fork Feedback

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

§
Posted: 2023-03-24

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
§
Posted: 2023-03-24

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.

§
Posted: 2023-03-24

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?

§
Posted: 2023-04-03

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
§
Posted: 2023-04-03
Edited: 2023-04-03

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...
})();

Post reply

Sign in to post a reply.