Skip to content

Instantly share code, notes, and snippets.

@edvakf
Created January 18, 2009 11:43
Show Gist options
  • Save edvakf/48621 to your computer and use it in GitHub Desktop.
Save edvakf/48621 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name fastladder_show_fc2_images.user.js
// @namespace http://d.hatena.ne.jp/edvakf/
// @description Make fc2 images viewable on LDR/Fastladder
// @include http://reader.livedoor.com/reader/
// @include http://reader.livedoor.com/public/*
// @include http://fastladder.com/reader/
// ==/UserScript==
(function(w,d){
function openImg(img){
var src = img.getAttribute('hoge');
var iframe = d.createElement('iframe');
iframe.style = 'position:absolute;border-width:0px;right:0;bottom:0;width:1px;height:1px;';
iframe.src = 'data:text/html,<head><meta http-equiv="Refresh" content="0;url='+src+'" /></head>';
iframe.onload = reloadImg(img,src,iframe);
d.body.appendChild(iframe);
}
function reloadImg(img,src,iframe){
setTimeout(function(){
img.src=src;
img.removeAttribute('hoge');
iframe.parentNode.removeChild(iframe);
},800);
}
window.addEventListener('load',function(){
var rightContainer = d.getElementById('right_container');
var expr = d.createExpression('//img[@src="fc2"]',null);
var re = /(<img.*?src)="([^"]+fc2[^"]+)"/g;
function hackReferer(){
var result = expr.evaluate(rightContainer,7,null);
for(var i=0,l=result.snapshotLength;i<l;i++){
openImg(result.snapshotItem(i));
}
setTimeout(hackReferer,1000);
}
hackReferer();
w.register_hook('BEFORE_PRINTFEED',function(feed){
feed.items.forEach(function(item){
if(item.link.indexOf('fc2')>=0){
item.body = item.body.replace(re,'$1="fc2" hoge="$2"');
}
});
});
},false);
})(this.unsafeWindow||window,document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment