Created
December 26, 2011 09:24
-
-
Save yesmeck/1520802 to your computer and use it in GitHub Desktop.
No image in douban group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name No Image In Douban Group | |
// @namespace douban.com | |
// @description No image in douban group | |
// @include http://www.douban.com/group/topic/* | |
// ==/UserScript== | |
var oContent = document.getElementById('content'); | |
var aImgs = oContent.getElementsByTagName('img'); | |
var iImgCount = aImgs.length; | |
for(var i = 0; i < iImgCount; i++) { | |
if(aImgs[i].src.indexOf("group_topic") != -1) { | |
oImgParent = aImgs[i].parentNode; | |
oSpan = oImgParent.getElementsByTagName('span'); | |
if(oSpan.length > 0) { | |
oImgParent.getElementsByTagName('span')[0].style.display = 'none' | |
} | |
oNewSpan = document.createElement("span"); | |
sTitle = ''; | |
if(aImgs[i].alt) { | |
sTitle = aImgs[i].alt; | |
} else { | |
sTitle = aImgs[i].src; | |
} | |
oNewSpan.innerHTML = '<a target="_blank" href="' + aImgs[i].src + '">'+sTitle+'</a>'; | |
oImgParent.insertBefore(oNewSpan, aImgs[i]); | |
aImgs[i].style.display = 'none'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment