Created
May 25, 2019 03:51
-
-
Save teichopsia/ee643008c431bf029e816f01bb22df56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Netflix minimal | |
// @description netflix minimal attract mode // disable attract sound and purge attract mode elements | |
// @namespace example.com | |
// @author kehlarn | |
// @homepageURL https://teichopsia.github.io/ | |
// @version 1 | |
// @match https://www.netflix.com/browse | |
// @grant none | |
// ==/UserScript== | |
function report(action,...rest){ | |
if(0){ | |
console.log('netflix minimal/'+action,rest); | |
} | |
} | |
function silence() { | |
var k=document.querySelector('.svg-icon-audio-on'); | |
var ke=document.createEvent('SVGEvents'); | |
ke.initEvent('click',true,true); | |
if(k&&ke) { | |
k.dispatchEvent(ke); | |
} else { | |
// if you only silence, this doesn't happen. purging overlapping dom elements at a similar time | |
// due to react loading can race and this error happens as the parent elements were nuked under you | |
//report('silence','element missing?'); | |
} | |
} | |
function dompurge(n,c,o){ | |
if(n.nodeType===1&&n.classList.contains(c)) { | |
report('purging ',n); | |
n.parentNode.removeChild(n); | |
// only one target element so this is safe for now | |
o.disconnect(); | |
} | |
} | |
function purge(){ | |
//static easy targets | |
var minimal=document.querySelectorAll('.billboard-row, .lolomoBigRow, .bigRow'); | |
[].forEach.call(minimal,function(c){c.parentNode.removeChild(c);report('purging ',c)}); | |
// originals is via a react mount so we have to monitor dom changes via mutation observer to nail it | |
var mo=MutationObserver; | |
var o=new mo(function(r){ | |
var fm='originals-panels-row'; | |
r.forEach(function(m){ | |
if(m.type=='childList'&&typeof m.addedNodes=='object'&&m.addedNodes.length) { | |
for(var i=0,z=m.addedNodes.length;i<z;i++) { | |
p=m.addedNodes[i]; | |
dompurge(p,fm,o); | |
} | |
}else if(m.type=='attribute'){ | |
dompurge(m.target,fm,o); | |
} | |
}); | |
}); | |
o.observe(document.querySelector('.mainView'),{childList:true,subtree:true,attributes:true}); | |
} | |
silence(); | |
purge(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment