You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Turtle/extension/player.js

17 lines
681 B
JavaScript

var playerReady = false;
const NETFLIX_VID_URL = /https?:\/\/www\.netflix\.com\/watch\/([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
document.addEventListener('click', (e) => {
if (!playerReady && window.location.toString().match(NETFLIX_VID_URL)) {
let s = document.createElement('script');
s.setAttribute('id', 'netflix');
s.src = chrome.runtime.getURL('netflix.js');
(document.head || document.documentElement).appendChild(s);
playerReady = true;
} else if (playerReady && !window.location.toString().match(NETFLIX_VID_URL)) {
playerReady = false;
window.parent.postMessage('video not ready', '*');
document.getElementById('netflix').remove();
}
});