Skip to content

Instantly share code, notes, and snippets.

@uhwot
Last active July 18, 2024 21:26
Show Gist options
  • Save uhwot/8250904f3e4bfbad684c5ec26943e082 to your computer and use it in GitHub Desktop.
Save uhwot/8250904f3e4bfbad684c5ec26943e082 to your computer and use it in GitHub Desktop.
allows logging in via auth tokens on play.qobuz.com
// ==UserScript==
// @name qobuz auth token login
// @namespace io.github.uhwot.qbztoken
// @match https://play.qobuz.com/*
// @grant none
// @version 1.0
// @author uh wot
// @description allows logging in via auth tokens on qobuz
// @homepageURL https://gist.github.com/uhwot/8250904f3e4bfbad684c5ec26943e082
// @downloadURL https://gist.github.com/uhwot/8250904f3e4bfbad684c5ec26943e082/raw/qbztoken.user.js
// @icon https://play.qobuz.com/resources/favicon/favicon-96x96.png
// @run-at document-start
// ==/UserScript==
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
function ass() {
if (window.location.pathname === "/login") {
waitForElm("div.LoginPage__content").then((_) => {
const element = document.querySelector("div.LoginPage__content")
const div = document.createElement("div")
div.setAttribute("style", "width: 100%")
const p = document.createElement("p")
p.innerText = "Token:"
p.setAttribute("style", "color: #FFFFFF")
div.appendChild(p)
const input = document.createElement("input")
input.setAttribute("class", "SearchBar__input")
input.setAttribute("type", "password")
input.setAttribute("style", "padding: 0px 10px 0px 10px; width: 100%")
input.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
event.preventDefault()
localStorage.setItem("shitass", input.value)
window.location = "https://play.qobuz.com/featured?code_autorisation=!shitass!"
}
})
div.appendChild(input)
element.appendChild(div)
})
}
}
const token = localStorage.getItem("shitass")
if (window.location == "https://play.qobuz.com/featured?code_autorisation=!shitass!" && token !== null) {
localStorage.removeItem("shitass")
window.fetch = (function (fetch) {
return async function (url, init) {
if (url.startsWith("https://www.qobuz.com/api.json/0.2/oauth/callback?code=!shitass!")) {
window.fetch = fetch
return new Response(JSON.stringify({
token: token,
user_id: "1"
}))
}
return await fetch(url, init)
}
})(window.fetch);
}
window.addEventListener('load', function() {
ass()
const replaceState = window.history.replaceState
Object.defineProperty(window.history, 'replaceState', {
get(_) {return function() {
replaceState.apply(window.history, arguments)
ass()
}},
set(_) {},
});
const pushState = window.history.pushState
Object.defineProperty(window.history, 'pushState', {
get(_) {return function() {
pushState.apply(window.history, arguments)
ass()
}},
set(_) {},
});
}, false)
@fafner8
Copy link

fafner8 commented Apr 5, 2024

Ok, thanks.

@CrossyAtom46
Copy link

@uhwot This is no longer working (at least for me) when i try to log-in play.qobuz.com redirects me to qobuz.com/signin

@uhwot
Copy link
Author

uhwot commented Jul 7, 2024

@CrossyAtom46 it still works for me
there's a textbox under the "login" and "signup" buttons, you're supposed to paste the token there and press enter

@CrossyAtom46
Copy link

@CrossyAtom46 it still works for me there's a textbox under the "login" and "signup" buttons, you're supposed to paste the token there and press enter

@uhwot I felt like I was blind, but the last time I used it, it wasn't like that. Thanks

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