Create a gist now

Instantly share code, notes, and snippets.

Bookmarklet to uncripple Kindle Cloud Reader
(function() {
function uncrippleFrame() {
var body = this.contentWindow.document.getElementsByTagName('body')[0];
this.contentWindow.onclick = null;
body._frame = this;
body.onmousemove = function() {
this._frame.contentWindow.onclick = null;
this.setAttribute('style', '-webkit-user-select: auto;');
this.oncontextmenu = body.onselectstart = null;
};
body.onmousemove();
};
var container = document.getElementsByTagName('iframe')[0].contentWindow;
var frames = container.document.getElementsByTagName('iframe');
for (var i = 0; i < frames.length; i++) {
uncrippleFrame.call(frames[i]);
frames[i].onload = uncrippleFrame;
}
})();
@kerim

Doesn't work on current stable version of Chrome for Mac (13.0.782).

@mzheng

This breaks keyboard navigation.

@jerodsanto
Owner

@kerim strange, it's not doing anything revolutionary that would require edge Chrome. Can you pop the Developer Console, use the bookmarklet, then look for any errors in the console? Report back if you find anything.

@jerodsanto
Owner

@mzheng indeed it does. Silly me, I didn't even know there was keyboard navigation.

I'm not sure why keyboard nav would break, unless it is somehow related to onclick? But that doesn't make much sense...

@kerim

It says "uncaught referenceerror: $ is not defined" (anonymous function)

@jerodsanto
Owner

@kerim I just ran the bookmarklet on Chrome for Mac (13.0.782.112) and it worked just fine. You're using it after the book has loaded into the page, right? Do you have any extensions running that may be interfering?

@trrichard

@sant0sk1 I'm experiencing the same problem as @kerim. It is probably related to jquery which defines the $('id') function as find component by ID. Your JS code work when run from the Chrome development console, just not as a bookmarklet. You should probably rewrite your bookmarklet to be independent of, or include the code to jquery.

@jerodsanto
Owner

@trrichard Amazon was loading jQuery into the global context, but it appears they aren't anymore. The bookmarklet now fails for me as well. I was just using jQuery because it was available and makes getting at elements easier. I'll rewrite it to use vanilla js dom tools instead.

@trrichard

Hey @sant0sk1 I forked and patched the bookmarklet so it loads jquery now before modifying the iframes. I recommend you merge till you fix it to work with out jquery.

@jerodsanto
Owner

@trrichard cool, I actually have a rewritten copy on my desktop, but haven't published it yet because amazon changed the way it works and they are resetting the original state anytime you reload content (when the loading spinner appears, not when navigating a single page).

I wanted to get that working first, but if you prefer I'll publish what I have.

@deadlyicon

works great as of today. I'm going to make this a glimmerblocker plugin so it just always runs =)

@JWamateur

i'm pretty new at this. downloaded the file, but can't get it to open in any of my browsers (tried IE and firefox). any suggestions?

@dhjdhj

Just tried it with Safari 5.1.4 on my Mac and it doesn't work at all. No errors in the dev console either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment