Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created August 10, 2011 16:31
Show Gist options
  • 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;
}
})();
@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