Skip to content

Instantly share code, notes, and snippets.

@vogler
Last active May 16, 2023 10:13
Show Gist options
  • Save vogler/344bb0a151810635aa5c25d11fc08179 to your computer and use it in GitHub Desktop.
Save vogler/344bb0a151810635aa5c25d11fc08179 to your computer and use it in GitHub Desktop.
Netflix: choose profile (TODO and enter its pin)
// ==UserScript==
// @name Netflix: choose profile (TODO and enter its pin)
// @namespace https://gist.github.com/vogler
// @downloadURL https://gist.github.com/vogler/344bb0a151810635aa5c25d11fc08179/raw/netflix-choose-profile.tamper.js
// @version 0.1
// @description Netflix: choose profile (TODO and enter its pin)
// @author Ralf Vogler
// @match https://www.netflix.com/browse*
// @icon https://www.google.com/s2/favicons?sz=64&domain=netflix.com
// @grant none
// ==/UserScript==
const profileIndex = 0; // 0-4
const profilePin = '0000'; // false or 4 digit pin as string (may have leading zero)
(async function() {
'use strict';
const chooseProfile = document.querySelector('.choose-profile');
if (chooseProfile) {
const profiles = document.querySelectorAll('.profile-link');
console.log(`Choose profile ${profileIndex+1} of ${profiles.length}`);
profiles[profileIndex].click();
if (profilePin) {
const inputs = document.querySelectorAll('.pin-number-input');
for (const i in inputs) {
// inputs[i].value = profilePin[i]; // fills values but not enough to trigger their js
}
// seems like event.isTrusted is not checked, but still does not work:
// document.querySelector('.pin-input-container').dispatchEvent(new KeyboardEvent('keypress',{'key':'3', 'bubbles': true}));
// akiraClient.js seems to do the event handling:
// relevant local function is changePinDigit (deep call stack, could not figure out how to call)
// which after the last digit calls "checkPin" (via key)
// which sends a POST request to /profileLock which
// which will respond with status 401 for a wrong pin
// Also tried to set React state via some functions visible in the DOM, but did not do anything.
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment