Created
April 13, 2016 11:52
-
-
Save duanckham/770d82bbbe9f62c7c2633cc763d62d2d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function() { | |
if (!document.body) { | |
return setTimeout(arguments.callee, 50); | |
} | |
var maxReplace = 5; | |
var doneCount = 0; | |
var slot_250_250_o = '_guanggao_pub = "d9c93a99008600ba3009"; _guanggao_slot = "8a86dc48598208373f2e";'; | |
var slot_250_250_s = 'http://x.chaoad.com/js/d9c93a99008600ba3009'; | |
var slot_300_250_o = '_guanggao_pub = "d9c93a99008600ba3009"; _guanggao_slot = "cf1a8eb17c3c0e9bbe7c";'; | |
var slot_300_250_s = 'http://x.chaoad.com/js/d9c93a99008600ba3009'; | |
var slot_336_280_o = '_guanggao_pub = "d9c93a99008600ba3009"; _guanggao_slot = "63a43f266831b1643d66";'; | |
var slot_336_280_s = 'http://x.chaoad.com/js/d9c93a99008600ba3009'; | |
var slot_728_90_o = '_guanggao_pub = "d9c93a99008600ba3009"; _guanggao_slot = "58f93570d8f765c51ae4";'; | |
var slot_728_90_s = 'http://x.chaoad.com/js/d9c93a99008600ba3009'; | |
var slot_760_90_o = '_guanggao_pub = "d9c93a99008600ba3009"; _guanggao_slot = "c529cff5ac3370469567";'; | |
var slot_760_90_s = 'http://x.chaoad.com/js/d9c93a99008600ba3009'; | |
var sizeList = { | |
'640_60': false, | |
'960_90': false, | |
'300_250': { o: slot_300_250_o, s: slot_300_250_s }, | |
'250_250': { o: slot_250_250_o, s: slot_250_250_s }, | |
'200_200': false, | |
'336_280': { o: slot_336_280_o, s: slot_336_280_s }, | |
'125_125': false, | |
'360_300': false, | |
'728_90': { o: slot_728_90_o, s: slot_728_90_s }, | |
'760_90': { o: slot_760_90_o, s: slot_760_90_s } | |
}; | |
var iframeEls = document.getElementsByTagName('iframe'); | |
var replaceEl = function(adEl, slot) { | |
var parentEl = adEl.parentNode; | |
var optionEl = document.createElement('script'); | |
var sourceEl = document.createElement('script'); | |
optionEl.type = sourceEl.type = 'text/javascript'; | |
optionEl.text = slot.o; | |
sourceEl.src = slot.s; | |
parentEl.insertBefore(sourceEl, adEl); | |
parentEl.insertBefore(optionEl, adEl); | |
parentEl.removeChild(adEl); | |
}; | |
for (var i in iframeEls) { | |
if (doneCount === maxReplace) { | |
break; | |
} | |
if (iframeEls[i].name === 'FOGFOUND') { | |
continue; | |
} | |
iframeEls[i].name = 'FOGFOUND'; | |
var width = iframeEls[i].width || iframeEls[i].offsetWidth; | |
var height = iframeEls[i].height || iframeEls[i].offsetHeight; | |
var size = width + '_' + height; | |
// FILTER BAIDU 300x250 | |
if (iframeEls[i].src && size == '300_250' && iframeEls[i].src.indexOf('pos.baidu.com') > 0) { | |
continue; | |
} | |
if (sizeList[size]) { | |
replaceEl(iframeEls[i], sizeList[size]); | |
doneCount++; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment