:clipboard: Description
Services : openuserjs.org, greasyfork.org
Information : Install count, rating, version code
Examples :
:link: Data
: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.
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.
Found the API for GreasyFork!
https://greasyfork.org/scripts/411035.jsonhttps://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 is the API documented anywhere? It would be quite useful!
Related issue: #829
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.
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.
Personally, I just filled the _Dynamic_ form with those values
jsonGreasyForkhttps://greasyfork.org/scripts/411035.jsontotal_installs#990000installs
The query is just a JSON Path. The only variable here is 411035, the script ID.
@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:
Thanks @Martii! I got it working.
jsonOpenUserJShttps://openuserjs.org/meta/NatoBoram/YouTube_Comment_Blacklist.meta.json$.OpenUserJS.installs[0].value#2c3e50installsI 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.
Most helpful comment
@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
UserScriptblock property but in theOpenUserJSblock. 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 appreciate the not scraping aspect. :smile_cat: