shields icon indicating copy to clipboard operation
shields copied to clipboard

Badge request : openuserjs.org, greasyfork.org

Open NatoBoram opened this issue 4 years ago • 12 comments

:clipboard: Description

Services : openuserjs.org, greasyfork.org

Information : Install count, rating, version code

Examples :

OpenUserJS GreasyFork

:link: Data

  • Public API
    • OpenUserJS : https://github.com/OpenUserJS/OpenUserJS.org/issues/77
    • GreasyFork : https://github.com/badges/shields/issues/5505#issuecomment-689578797
  • No key needed
  • No documentation

:microphone: Motivation

This feature can help assert a certain "reputation" based on install count for public scripts.

More specifically, I want to be able to show off that people have installed my userscript.

NatoBoram avatar Sep 08 '20 21:09 NatoBoram

Thanks for the request @NatoBoram. However, we can't do html scraping to retrieve the requisite data for the badges. If these tools/services do not provide an endpoint to retrieve the data, then we can't provide native badges for them, but you could leverage our Endpoint badge instead.

calebcartwright avatar Sep 08 '20 21:09 calebcartwright

Found the API for GreasyFork!

  • https://greasyfork.org/scripts/411035.json
  • GreasyFork
  • https://img.shields.io/badge/dynamic/json?color=%23990000&label=GreasyFork&query=total_installs&suffix=%20installs&url=https%3A%2F%2Fgreasyfork.org%2Fscripts%2F411035.json

NatoBoram avatar Sep 09 '20 13:09 NatoBoram

@NatoBoram is the API documented anywhere? It would be quite useful!

PyvesB avatar Sep 09 '20 15:09 PyvesB

Related issue: #829

jerone avatar Sep 09 '20 15:09 jerone

I don't think there's a documentation anywhere. I found out in https://github.com/JasonBarnabe/greasyfork/issues/247 that you can add .json to some web pages and it'll return a JSON response.

Their example is https://greasyfork.org/users/173559.json, so I tried on my script and https://greasyfork.org/scripts/411035.json works.

I asked in https://github.com/JasonBarnabe/greasyfork/issues/787.

NatoBoram avatar Sep 09 '20 16:09 NatoBoram

Well I'll have to reread Shields documents and find out how they are actually querying any site to add this to OUJS e.g. this part query=total_installs&suffix=%20installs... if it's a QSP it may be doable on our own since we do have a documented .json routine (just no QSP's atm to pull individual elements out)... if it's a headered request that will need to be a collaboration with Shields and some tighter restrictions.

In other words need to dig in their docs and code to see for sure.

Martii avatar Sep 09 '20 22:09 Martii

Personally, I just filled the Dynamic form with those values

  • json
  • GreasyFork
  • https://greasyfork.org/scripts/411035.json
  • total_installs
  • #990000
  • installs

image

The query is just a JSON Path. The only variable here is 411035, the script ID.

NatoBoram avatar Sep 10 '20 00:09 NatoBoram

@NatoBoram Well the documentation is at https://openuserjs.org/about/Frequently-Asked-Questions#q-does-openuserjs-org-have-meta- and my Unit Test for the site is at https://openuserjs.org/scripts/Marti/oujs_-_Meta_View (which just happens to utilize install count for that .user.js to fill out the phantom URL UI) which will show the .json fields we collect. If you need something added let us know on OUJS GH dev. If it's not too DB intensive it can probably be added.

So if Shields can parse that on their end via their QSP's it may work for you as is. Make note some of the info you are looking for is not in the UserScript block property but in the OpenUserJS block. i.e. we have multiple tiers in the JSON. I specifically made the .json available myself and it was adopted later by others.

@calebcartwright

we can't do html scraping to retrieve the requisite data for the badges.

We appreciate the not scraping aspect. :smile_cat:

Martii avatar Sep 10 '20 01:09 Martii

Thanks @Martii! I got it working.

  • json
  • OpenUserJS
  • https://openuserjs.org/meta/NatoBoram/YouTube_Comment_Blacklist.meta.json
  • $.OpenUserJS.installs[0].value
  • #2c3e50
  • installs

OpenUserJS

I do wonder why installs is an array, though.

I had to use jsonpathfinder to find the correct path, but with this tool it's very easy.

ghost avatar Sep 10 '20 18:09 ghost

https://github.com/JasonBarnabe/greasyfork/wiki/API

NatoBoram avatar Sep 13 '20 06:09 NatoBoram

Hello, any news on this ? Thanks !

KaKi87 avatar Nov 29 '21 11:11 KaKi87

Hello, any news on this ? Thanks !

We post updates as and when they are available, so as a general rule of thumb, the absence of updates should be interpreted as meaning there are no updates and there is no news. That applies here as well.

A json endpoint is a perfectly viable data retrieval target for us, and we've a number of badges that fetch data via a similar mechanism. As such, it should indeed be possible for someone to submit a PR with the requisite code to add these badges. We've got a solid tutorial that provides a step by step guide for anyone sufficiently interested in working on this.

We view Shields as a community project that's stewarded by us as a small maintainer team (with limited bandwidth). We're happy to provide guidance and assistance to anyone from the community that wants to try to implement the badge(s), but to be fully transparent, it's rather unlikely that it'll ever be implemented by a maintainer.

In the interim, a number of folks have posted available options which utilize our Dynamic Badge feature that can be leveraged today.

calebcartwright avatar Nov 29 '21 21:11 calebcartwright