badges / shields

Concise, consistent, and legible badges in SVG and raster format
https://shields.io
Creative Commons Zero v1.0 Universal
23.66k stars 5.49k forks source link

Badge request : openuserjs.org, greasyfork.org #5505

Open NatoBoram opened 4 years ago

NatoBoram commented 4 years ago

:clipboard: Description

Services : openuserjs.org, greasyfork.org

Information : Install count, rating, version code

Examples :

OpenUserJS GreasyFork

: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.

calebcartwright commented 4 years ago

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.

NatoBoram commented 4 years ago

Found the API for GreasyFork!

PyvesB commented 4 years ago

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

jerone commented 4 years ago

Related issue: #829

NatoBoram commented 4 years ago

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.

Martii commented 4 years ago

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.

NatoBoram commented 4 years ago

Personally, I just filled the Dynamic form with those values

image

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

Martii commented 4 years ago

@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:

ghost commented 4 years ago

Thanks @Martii! I got it working.

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.

NatoBoram commented 4 years ago

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

KaKi87 commented 2 years ago

Hello, any news on this ? Thanks !

calebcartwright commented 2 years ago

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.