logoalt Hacker News

susamyesterday at 11:50 PM0 repliesview on HN

I often write small userscripts to neutralise hostile or annoying UI patterns. I played the 'Hostile Volume' game for a while. Nice game! After a while, I wondered: if this were a real hostile website, could I write a userscript to make each level happy? Here is the script:

  // ==UserScript==
  // @name  Hostile Volume Winner
  // @match https://hostilevolume.com/
  // ==/UserScript==
  (function () {
    const s = document.createElement('script')
    s.textContent = `
      (function () {
        function visible (id) {
          return !document.getElementById(id).classList.contains('hidden')
        }
        function win () {
          if (visible('victory-screen')) return
          if (visible('instructions-modal')) {
            document.getElementById('start-btn').click()
            setTimeout(win, 2000)
            return
          }
          setTimeout(function () {
            document.getElementById('l13-age-input').value = '01011970'
            window.cancelAnimationFrame(levels[currentLevelIndex].frame)
          }, 100)
          window.setVolume(25)
          setTimeout(win, 3500)
        }
        win()
      })()
    `
    document.body.appendChild(s)
  })()
If you don't have a userscript manager, you can just copy the script between the two backticks and paste it to the web browser's Developer Tools console.