Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.