aboutsummaryrefslogtreecommitdiffstats
path: root/content.js
diff options
context:
space:
mode:
authorTeddy Wing2020-05-06 00:57:29 +0200
committerTeddy Wing2020-05-06 01:00:59 +0200
commit50859155dff9a85645dbfddf166ed888756be107 (patch)
treeef815d3a67d7e270e37375261c2418fb0fdddfdd /content.js
parent0c56f4361c836f15d22daf7ce70570f9f95afdae (diff)
downloadnetflix-immersive-50859155dff9a85645dbfddf166ed888756be107.tar.bz2
Convert from a web extension to a user script
Since it looks like everything's going to happen in the content script, might as well make this a user script instead. Build with Browserify in order to get a compiled JS file compatible with browsers. For some reason I'm currently getting an error complaining that the `stylesheet` variable is `null`. Need to look into that.
Diffstat (limited to 'content.js')
-rw-r--r--content.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/content.js b/content.js
deleted file mode 100644
index bcf10dd..0000000
--- a/content.js
+++ /dev/null
@@ -1,84 +0,0 @@
-function with_player (callback) {
- var interval = setInterval(
- function() {
- var player = document.querySelector('.NFPlayer.nf-player-container');
-
- if (player) {
- clearInterval(interval);
-
- callback(player);
- }
- },
- 1000
- );
-}
-
-function init_mutation_observer (player) {
- var observer = new MutationObserver(function(mutation_list) {
- for (var i = 0; i < mutation_list.length; i++) {
- var mutation = mutation_list[i];
-
- if (mutation.target.classList.contains('postplay')) {
- mutation.target.classList.remove('postplay');
-
- // Activate player controls.
- mutation.target.click();
-
- // TODO: Change .active to .inactive
- // mutation.target.classList.replace('active', 'inactive'); // Didn't work
- // Remove .can-resume: Removes white border on hover
- // PlayerControlsNeo__bottom-controls PlayerControlsNeo__bottom-controls--faded
- // PlayerControlsNeo__layout PlayerControlsNeo__layout--active
- // PlayerControlsNeo__layout PlayerControlsNeo__layout--inactive
-
- // document.querySelector('.PlayerControlsNeo__bottom-controls')
- // .classList
- // .add('PlayerControlsNeo__bottom-controls--faded');
-
- document.querySelector('.PlayerControlsNeo__layout.PlayerControlsNeo__layout--active')
- .classList
- .replace(
- 'PlayerControlsNeo__layout--active',
- 'PlayerControlsNeo__layout--inactive'
- );
-
- // .OriginalsPostPlay-BackgroundTrailer .BackToBrowse
-
- return;
- }
- }
- });
-
- observer.observe(
- player,
- {
- attributeFilter: ['class'],
- attributeOldValue: true
- }
- );
-}
-
-function styles () {
- var style = document.createElement('style');
-
- document.head.appendChild(style);
-
- style.sheet.insertRule(
- '.OriginalsPostPlay-BackgroundTrailer .BackToBrowse { visibility: hidden; }',
- style.sheet.cssRules.length
- );
-
- style.sheet.insertRule(
- '.player-view-childrens { visibility: hidden; }',
- style.sheet.cssRules.length
- );
-}
-
-
-with_player(function(player) {
- window.player = player;
-
- init_mutation_observer(player);
-});
-
-styles();