I was trying to update my Netflix autoplay bookmarklet since the autoplay feature that Netflix came out with is…not great. What I found was that Netflix tried to disable the console. Well, that became a more interesting problem to solve…and quite an easy one too. The code Netflix uses to disable the console is:
(function () { try { var $_console$$ = console; Object.defineProperty(window, "console", { get: function () { if ($_console$$._commandLineAPI) throw "Sorry, for security reasons, the script console is deactivated on netflix.com"; return $_console$$ }, set: function ($val$$) { $_console$$ = $val$$ } }) } catch ($ignore$$) {} })();
To undo this is actually really simple, we just need to set the getter/setter back to 'undefined' and everything is happy:
Object.defineProperty(window, "console", { get: undefined, set: undefined });
And of course this is easy to make into a bookmarklet like so:
Enable Console
Sorry Netflix =)
Pingback: NEW Netflix Autoplay Bookmarklet! | Mostly Worthless
Re:
1.Object.defineProperty(window, “console”, {
2.get: undefined,
3.set: undefined
4.});
I HAVE NEVER STUDIED CODE (yet). (Sorry for all caps). I notice the Netflix “fix” starts “Object…” on line 4, you begin Line 1. Is this important? or do I add this BEFORE or AFTER the Netflix goop?
And of course this is easy to make into a bookmarklet like so:
What is a bookmarklet and where do I place the following: “Enable Console”?
As I mentioned in a previous comment, the fact that the last update was 2.5 years ago and I use OSX, means I won’t be trying your extension yet but to get in and check out the code would be very interesting.
They start it on line 4 because they are doing other things before that. What they are doing is actually important for them, but for what I am doing, it is not. They are wrapping it in an IIFE (https://en.wikipedia.org/wiki/Immediately-invoked_function_expression) and a try/catch (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try…catch)
A bookmarklet just means you can drag that link up to your bookmark bar and it will work directly from there.