aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2020-05-03 19:52:55 +0200
committerTeddy Wing2020-05-03 19:52:55 +0200
commit025ac918d537ff779816972e67217ace5422e58b (patch)
tree7ab18a26c270e63637d011b06cdb10cf64158280
parentfb2a8ddc4a4a6391e4ea142bcf5869cc14c2973a (diff)
downloadnetflix-immersive-025ac918d537ff779816972e67217ace5422e58b.tar.bz2
Old background and content scripts
Back when I first tried writing this, I explored a couple ideas using the `skipCreditsEnabled` and `wwwplayer.config.skip.credits.enabled` properties initialised on Netflix pages. The first idea was to use a content script to change these values from `true` to `false`. However, I found that this didn't do anything, very likely because the global configs are read at load time, and my script didn't overwrite them early enough. I tried setting `"run_at": "document_start"` in the `content_scripts` manifest, but that didn't do anything either. The next idea was to use the `webRequest` API in a background script to rewrite these properties before the page was rendered in the browser. The problem with that idea was that you're not allowed to modify the response body using this API. You can only modify headers. That's where I stopped. Today, I picked up the project again, this time using Mitmproxy to modify the response body and flip these two properties. The properties were correctly set to false, but it turns out that didn't change the windowed-video-credits behaviour. Only then did I realise that these properties instead probably control whether the "Skip Credits" _button_ is displayed or not, and have nothing to do with the small-frame video. This is indicated by the `skipCreditsDisplayDuration` property, which is set to 6000, likely meaning that the button should display for 6 seconds. I don't know why it took me so long, but the real answer is so simple and obvious: use CSS instead. The video player is assigned different classes once the credits start rolling. All we need to do is: * Ensure these classes don't get applied, or their styles don't get applied * Ensure the "Back to Browse" button doesn't show * Ensure the video controls still display when hovering over the video (possibly by virtually clicking on the video)
-rw-r--r--background.js18
-rw-r--r--content.js8
2 files changed, 26 insertions, 0 deletions
diff --git a/background.js b/background.js
new file mode 100644
index 0000000..fe1179d
--- /dev/null
+++ b/background.js
@@ -0,0 +1,18 @@
+browser.webRequest.onCompleted.addListener(
+ function(details) {
+ var filter = browser.webRequest.filterResponseData(details.requestId);
+
+ filter.onstop = function(event) {
+ var data = event.data;
+
+ // TODO: transform `data`
+
+ filter.write(data);
+ filter.disconnect();
+ };
+ },
+ {
+ urls: ['https://www.netflix.com/watch/*'],
+ types: ['main_frame']
+ }
+);
diff --git a/content.js b/content.js
new file mode 100644
index 0000000..b6a0cdc
--- /dev/null
+++ b/content.js
@@ -0,0 +1,8 @@
+// Didn't work
+netflix.reactContext.models.truths.data.skipCreditsEnabled = false;
+
+// Didn't work
+netflix.reactContext.models.truths.data['wwwplayer.config.skip.credits.enabled'] = false
+
+// Didn't work
+netflix.reactContext.models.fastProps.data['wwwplayer.config.skip.credits.enabled'] = false