Skip to content

Instantly share code, notes, and snippets.

@A-312
Last active May 2, 2023 21:09
Show Gist options
  • Save A-312/de155f4753463dce1d8910ad859f944f to your computer and use it in GitHub Desktop.
Save A-312/de155f4753463dce1d8910ad859f944f to your computer and use it in GitHub Desktop.
// ==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;
})
@hsandt
Copy link

hsandt commented May 2, 2023

Thanks for the gist!

I added shortcuts to check other platforms too. Replace

if (e.keyCode !== 120)
      return;

with:

  if (e.keyCode !== 117 && e.keyCode !== 121 && e.keyCode !== 119 && e.keyCode !== 120)
      return;

  var searched_link_id;
  if (e.keyCode == 117) {
    // F6: Windows
    searched_link_id = 42337;
  } else if (e.keyCode == 121) {
    // F10: OSX
    searched_link_id = 42339;
  } else if (e.keyCode == 119) {
    // F8: Linux
    searched_link_id = 42341;
  } else if (e.keyCode == 120) {
    // F9: Web
    searched_link_id = 42336;
  }

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment