1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | // ==UserScript==
// @name Qobuz Credentials Logger
// @namespace http://tampermonkey.net/
// @version 0.0.1
// @description log Qobuz user credentials to console
// @author FrankYaLatr
// @match https://play.qobuz.com/*
// @match https://www.qobuz.com/*
// @icon https://www.qobuz.com/favicon.ico
// @grant none
// ==/UserScript==
(function () {
'use strict';
const outputStyle = `
font-size: x-large;
font-weight: bold;
`;
const logCredentials = true;
if (window.location.origin.startsWith('https://play.')) {
restoreConsole();
const user = getUserCredentials();
if (window.self !== window.top) {
window.parent.postMessage({ user }, '*');
return;
}
if (user) {
window.user = user;
logUserCredentials();
}
observePage();
return;
}
window.addEventListener('message', (e) => {
window.user = e.data.user;
logUserCredentials();
});
embedPlaySite();
function getUserCredentials() {
const localStorageUserData = window.localStorage.getItem('localuser');
if (!localStorageUserData) return;
const user = JSON.parse(localStorageUserData);
return { country: user.country_code, id: user.id, token: user.token };
}
function observePage() {
let oldPath = window.location.pathname;
const observer = new MutationObserver(mutations => {
mutations.forEach(() => {
if (oldPath === window.location.pathname) { return; }
const user = getUserCredentials();
window.user = user;
if (oldPath.includes('/login')) {
logUserCredentials();
}
oldPath = window.location.pathname;
});
});
observer.observe(document.body, { childList: true, subtree: true });
}
function logUserCredentials() {
if (!(logCredentials && window.user)) { return; }
console.log('%cCredentials:', outputStyle);
console.table(window.user);
}
function restoreConsole() {
const i = document.createElement('iframe');
i.style.display = 'none';
document.body.appendChild(i);
window.console = i.contentWindow.console;
}
function embedPlaySite() {
const fr = document.createElement('iframe');
fr.src = 'https://play.qobuz.com';
fr.style.display = 'none';
document.body.appendChild(fr);
}
})();
|