Skip to content

Instantly share code, notes, and snippets.

@firedfox
Last active December 22, 2015 15:38
Show Gist options
  • Save firedfox/6493256 to your computer and use it in GitHub Desktop.
Save firedfox/6493256 to your computer and use it in GitHub Desktop.
const AD_ID:String = 'bab76d78ff916132c83833ae30776fb7';
var isMktSent:Boolean = isMktSent;
if (ExternalInterface.available && !isMktSent && (isMktSent = true)) {
ExternalInterface.addCallback('getMktAdId', function():String { return AD_ID; });
ExternalInterface.call(['eval(\'(function() {',
'var o = document.getElementsByTagName("*");',
'for (var i in o) {',
'if (o[i].getMktAdId && o[i].getMktAdId() == "' + AD_ID + '") {',
'var hook = document.createElement("div"); hook.id = "_bdhm_mkt_' + AD_ID + '";',
'if (o[i].nextSibling) { o[i].parentNode.insertBefore(hook, o.nextSibling); }',
'else { o[i].parentNode.appendChild(hook); }',
'}',
'}',
'var mkt = document.createElement("script"); mkt.src = "//click.hm.baidu.com/mkt.js?' + AD_ID + '";',
'var h = document.getElementsByTagName("head"); h && h[0].appendChild(mkt);',
'})();\')'].join(''));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment