Request: Background image to img
|
|
Hello, I would like to have a script that makes this line:
to:
Possible? :D |
|
|
One possible way:
(function(){
var divs=document.getElementsByTagName('div');
for(var i=0;i<divs>-1){
url=url.substr(url.indexOf("url")+4);
url=url.substr(0,url.indexOf(")"));
GM_log(url);
GM_log(divs[i].getElementsByTagName('img')[0].src);
divs[i].getElementsByTagName('img')[0].src=url;
}
}
}
})();
divs[i].getElementsByTagName('img') should get imgs only from that DIV, though i have not used it that way :P |
|
|
I'm yet to discover a nicer way to get the url from style.background :P
|
|
|
var divs = document.evaluate("//div[contains(@style, 'background')]",
document, null, 6, null);
for (var i = 0; i < divs.snapshotLength; i++) {
var div = divs.snapshotItem(i);
var img = div.getElementsByTagName("img")[0];
var src = div.style.backgroundImage.match(/\((\S+(?=\)))/)[1];
div.style.backgroundImage = "none";
img.src = src;
}
|
|
|
thanks!!! amazing what you people can do!:) |
