Created
July 27, 2023 17:48
-
-
Save nickadam/e1532e9df9ca3cbc4138efcd6cb46fcd to your computer and use it in GitHub Desktop.
Tampermonkey script for Spotify delay play for Quest 2 VR
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 Spotify delay play for Quest 2 VR | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Hits the play button after a delay so you can listen to spotify on Oculus Quest 2. You can sideload firefox android app with sidequest, add the tampermonkey add-on, add this script, and open spotify in desktop mode in firefox, move it to a sidepanel, start playing what you want, pause it, hit "Play in 15s", open your VR game of choice. | |
// @author Nick Vissari | |
// @match *://open.spotify.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=spotify.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(() => { | |
//document.evaluate("//button[contains(@aria-label, 'Play')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue | |
const play_button = document.querySelectorAll('[data-testid="control-button-playpause"]')[0] | |
if(!play_button) return | |
let delay_button = document.getElementById('delay_play') | |
if(!delay_button){ | |
// add delay play button | |
let indicator = document.createElement('span') | |
indicator.innerHTML = '👍' | |
indicator.hidden = true | |
delay_button = document.createElement('span') | |
delay_button.setAttribute('id', 'delay_play') | |
delay_button.innerHTML = 'Play in 15s' | |
delay_button.onclick = () => { | |
delay_button.hidden = true | |
indicator.hidden = false | |
setTimeout(() => { | |
play_button.click() | |
delay_button.hidden = false | |
indicator.hidden = true | |
}, 15000) | |
} | |
play_button.after(delay_button) | |
play_button.after(indicator) | |
} | |
}, 1000) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns out firefox closes immediately when you open another app. But the built in quest browser remains open. I deployed jellyfin, added some songs, and added the above code (almost verbatim) to main.jellyfin.bundle.js.
This is the only change required: