Bringing back the console API on Netflix and Facebook

Facebook and Netflix have implemented some code that breaks the console API in Chrome by changing the getter/setter for the console property on the window object. The purpose is noble – to help avoid a social engineering attack – but as a developer it irks me. I want my console when and where I want it.  In short order, Zach and I had a fix in place that unbreaks the console.

Using dotjs – which I’ve written about at Gigaom Kitchen – we can run the following code before the console-breaking code executes (here’s my dotjs file):

var s = document.createElement('script');
s.innerHTML = 'Object.defineProperty(window, "console", {writable: false});';
document.head.appendChild( s );

MDN writes on the writable property:

When the writable property attribute is set to false, the property is said to be “non-writable”. It cannot be reassigned.

Now I get my console :)

Chromedriver doesn’t run in tmux and here’s how to fix it

Aw, Snap ScreenshotIf you are attempting to run Selenium using the Chromedriver while in a tmux session, you may have encountered some issues with chromedriver.  Specifically, this error:

Aw, Snap!

Something went wrong while displaying this webpage. To continue, reload or go to another page.

If you’re seeing this frequently, trie these suggestions.

A simple solution is to just execute the Selenium jar in a shell session outside of your good friend, tmux.

java -jar ~/bin/selenium-server-standalone-2.33.0.jar -browserSessionReuse -Dwebdriver.chrome.driver=bin/chromedriver

One of my friends, however, alerted me to this article that has a solution:

  • Get Homebrew, if you don’t already have it.
  • brew install reattach-to-user-namespace
  • Add the following line to your .tmux.conf file: set-option -g default-command "reattach-to-user-namespace -l zsh" (replace zsh with bash if you use that)

This fix also resolves the issue that prevents pbcopypbpaste, etc from working in tmux!

Google Chrome on the Mac – a la CodeWeavers

Google launched its new browser Chrome on September 2nd and the web was abuzz with talk of a new contender in the browser space. My choice to pepper my house and cube at work with Macs rather than Windows boxes left me complaining about the lack of a native Mac version of Chrome…which Google assures us is coming.

Code Weavers, however, has just released Crossover Chromium built from build 21 of the Chromium Open Source browser.

Chromium

The initialization of Chromium the first time I opened it took a while but once it was up and running, things were pretty solid. The browser has all the JavaScript and DOM debugging tools but it seems the process manager tool isn’t fully functional..which is really my draw to the browser (when I get dead set on playing with the Process Manager tool, I’ll break down and install Chrome with Parallels). I suppose I’ll be following CodeWeaver’s suggestion:

Q. Should I run CrossOver Chromium as my main browser?

A. Absolutely not! This is just a proof of concept, for fun, and to showcase what Wine can do. Chromium itself is just beginning. As the Chromium project progresses, they will be providing more compelling support for Mac OS and Linux, particularly with process security and memory management. Those future versions from Chromium will be better suited for daily use than this version.

Until Google launches its official Mac native Chrome, Chromium will satisfy me for now.