Skip to content

Instantly share code, notes, and snippets.

@BoLaMN
Last active December 30, 2019 04:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BoLaMN/58f5c87c39f7e4bf800baf6cf1310f40 to your computer and use it in GitHub Desktop.
Save BoLaMN/58f5c87c39f7e4bf800baf6cf1310f40 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name netflix
// @namespace http://tampermonkey.net/
// @version 0.3
// @description try to take over the world!
// @author You
// @match *://www.netflix.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
'use strict';
const listeners = [];
const check = function() {
for (let listener of listeners) {
const elements = document.querySelectorAll(listener.selector);
for (let element of elements) {
if (!element.ready) {
element.ready = true;
listener.fn.call(element, element);
}
}
}
};
const observer = new MutationObserver(check);
observer.observe(document.documentElement, {
childList: true,
subtree: true
}
);
const watch = function(selector, fn) {
listeners.push({ selector, fn });
check();
return function() {
var idx = listeners.findIndex(function(listener) {
return listener.selector === selector
})
if (idx > -1) { listeners.splice(idx, 1) }
}
};
// skip intro
watch('.skip-credits', function(element) {
console.log(element)
var skip = element.children[0]
var unwatch = watch('.button-nfplayerPlay', function(play) {
console.log('play button found, clicking')
play.click()
})
skip.click()
setTimeout(unwatch, 1000)
})
// auto play next
//watch('.nf-flat-button-icon-play', element => element.parentElement.click())
watch('button[data-uia="next-episode-seamless-button"]', element => element.click())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment