minagi
10/11/2014 - 2:34 AM

BOOKMARKLET: View original size of twimg

BOOKMARKLET: View original size of twimg

// BOOKMARKLET: View original size of twimg
// cf. http://storagebox.xxxxxxxx.jp/tools/twitter_img_originalsize.html
// 2014/10/11 fix: 元ソースより、画像を複数含むpost表示時のマッチ条件を修正

javascript:url=location.href;
src=document.getElementsByTagName('html')[0].innerHTML;
resul=url;

if(url.match(new RegExp('pbs.twimg.com','i'))){
	if(url.match(RegExp(':large','i'))){
		str=RegExp.leftContext
	}else if(url.match(RegExp(':thumb','i'))){
		str=RegExp.leftContext
	}else if(url.match(RegExp(':orig','i'))){
		str=RegExp.leftContext
	}else{
		str=url
	}
	resurl=str+':orig';
	location.href=resurl
}else if(src.match(new RegExp('multi-photos','i'))){
	str=RegExp.rightContext;
	while(str.match(RegExp('data-resolved-url-large=','i'))){
		str=RegExp.rightContext;
		if(str.match(RegExp('pbs.twimg.com/media/','i'))){
			str=RegExp.rightContext;
			if(str.match(RegExp('"','i'))){
				str2=RegExp.leftContext;
				resurl='https://pbs.twimg.com/media/'+str2+':orig';
				window.open(resurl);
				void(0)
			}
		}
	}
}else if(src.match(new RegExp('media media-thumbnail twitter-timeline-link is-preview','i'))){
	str=RegExp.rightContext;
	if(str.match(RegExp('pbs.twimg.com/media/','i'))){
		str=RegExp.rightContext;
		if(str.match(RegExp('large','i'))){
			str=RegExp.leftContext;
			str=str.substr(0,str.length-1);
			resurl='https://pbs.twimg.com/media/'+str+':orig';
			window.open(resurl);
			void(0)
		}
	}
}