Skip to content

Instantly share code, notes, and snippets.

@ikaflower
ikaflower / EmbedImagesOnHtml.js
Created September 4, 2011 06:04
Embed images on html file in base64 except images on diffirent domain(because of same-origin policy).
var notEmbedLength=600*1024;/*600KB*/
var d=document;
var imgs=d.getElementsByTagName('img');
for(var i=0;i<imgs.length;i++){
var src=new String(imgs[i].getAttribute('src'));
if(!src.match(/^[\/.]/m)&&!src.match(new RegExp('https?:\/\/'+window.location.hostname,'i')))
continue;
@ikaflower
ikaflower / IntelligentContentExtractor(original).js
Created September 4, 2011 00:32
Extract body text from web page.
var d=document;
var innerTextExists=(d.body.firstChild.innerText!=undefined);
var getElementText=function(e){
return innerTextExists?e.innerText:e.textContent;
};
var setElementText=function(e,val){
if(innerTextExists){
e.innerText=val;
}else{
@ikaflower
ikaflower / SendGreatQuery
Created September 2, 2011 02:11
SendGreatQuery sends url query replaced with "great" value.
javascript:(function(){mV=function(){i=0xFF;r="";while(i-->0)r+='%'+(i<=16?0:'')+i.toString(16);return r;};var loc=document.location;if(!loc.search)alert("このURLにはクエリがねえでゲソ");v=mV();loc.href=loc.href.replace(/\?.*/,'?')+loc.search.substr(1).replace(/([^=&]+)=[^=&]*/g,'$1='+v);})()