Last active
May 2, 2023 21:09
-
-
Save A-312/de155f4753463dce1d8910ad859f944f to your computer and use it in GitHub Desktop.
Ludumdare - displays HTML5 games https://ldjam.com/events/ludum-dare/46/rescue-turtles-1/$200707
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Ludumdare - displays HTML5 games | |
// @namespace ldjam-html5-games | |
// @version 4 | |
// @homepageURL https://ldjam.com/events/ludum-dare/46/rescue-turtles-1/displays-border-if-game-is-html5-or-not | |
// @updateURL https://gist.github.com/A-312/de155f4753463dce1d8910ad859f944f/raw/ldjam-html5-games.user.js | |
// @downloadURL https://gist.github.com/A-312/de155f4753463dce1d8910ad859f944f/raw/ldjam-html5-games.user.js | |
// @supportURL https://gist.github.com/A-312/de155f4753463dce1d8910ad859f944f | |
// @description Displays HTML5 games | |
// @author A-312 | |
// @match https://ldjam.com/events/ludum-dare/*/games* | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener("keydown", function (e) { | |
if (e.keyCode !== 120) | |
return; | |
(function HTML5only(A3i, list) { | |
const match = list[A3i].href.match(/\/events\/ludum-dare\/(\d+)\/(.+)/) | |
const session = match[1] | |
const queryid = match[2] | |
if (list[A3i].getAttribute('data-already') == '1') { | |
return HTML5only(A3i+1, list) | |
} | |
const req = new XMLHttpRequest() | |
req.responseType = 'json' | |
req.open('GET', `https://api.ldjam.com/vx/node2/walk/1/events/ludum-dare/${session}/${queryid}?node`, true) | |
req.onload = function() { | |
try { | |
const jsonResponse = req.response | |
const meta = jsonResponse.node[0].meta | |
const keys = Object.keys(meta).filter((a) => a.indexOf('-tag') !== -1) | |
const found = keys.filter((a) => meta[a] == 42336) | |
console.log(meta, keys, found) | |
if (found.length > 0) | |
list[A3i].style.border = '5px solid chartreuse' | |
else | |
list[A3i].style.border = '5px solid red' | |
} catch (e) { console.error(e) } | |
list[A3i].setAttribute('data-already', '1') | |
HTML5only(A3i+1, list) | |
}; | |
req.send(null) | |
})(0, document.querySelectorAll('div.layout-container > div > a.button-base.button-link.content-box')) | |
return false; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the gist!
I added shortcuts to check other platforms too. Replace
with:
then replace 42336 in the meta[a] check with
searched_link_id
You'll need to refresh to run a different search though. You could remove
data-already
to allow re-running searches at will, but I fear about the implications in performance.In addition, it only works if the developer added one link for each platform. Direct downloads and single links to itch.io, etc. won't be detected.
For now, going on itch and filtering by Ludum Dare tag + platform seems the best bet. But it only works for games on itch, and it cannot sort with the Ludum Dare need rating / smart karma system.