Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created August 10, 2011 16:31
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jerodsanto/1137337 to your computer and use it in GitHub Desktop.
Save jerodsanto/1137337 to your computer and use it in GitHub Desktop.
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
Copy link

kerim commented Aug 10, 2011

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

@mzheng
Copy link

mzheng commented Aug 11, 2011

This breaks keyboard navigation.

@jerodsanto
Copy link
Author

@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
Copy link
Author

@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
Copy link

kerim commented Aug 13, 2011

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

@jerodsanto
Copy link
Author

@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
Copy link

@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
Copy link
Author

@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
Copy link

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
Copy link
Author

@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.

@jaredatron
Copy link

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

@JWamateur
Copy link

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
Copy link

dhjdhj commented Mar 23, 2012

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