david-sabata/Chrome-Last.fm-Scrobbler — pull request #327 by Daniel15 (2014-03-03 05:34:56+00:00)
Title: Cleaner, more reliable connector for Digitally Imported

Rather than listening to DOM mutations, this injects a script into the page's scope (via a similar method to what the Jango and PlugDJ connectors do) and listens directly to JavaScript events fired by their player. Unlike the Jango and PlugDJ connectors which use a hacky method for communication (listening to DOM mutations on a hidden `div`), this one communicates to the extension via `window.postMessage` which is a lot cleaner. The script to inject the script is also cleaner and has been generalised in `inject.js` for easy reuse.

Open question: Is `window.postMessage` the cleanest way to do this? Should I be using an extension-specific API instead?