淘点金js代码自动跳转到爱淘宝(淘宝客)
本文介绍如何使用js代码直接把淘宝商品用淘点金转换为淘宝客链接,直接跳到爱淘宝。
需要jquery,自己加载一下。演示网站:http://www.9you9.cn/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="robots" content="noindex,nofollow"> <title>九邮九商品跳转中...</title> <script type="text/javascript" src='http://www.9you9.cn/Public/js/jquery-1.8.3.js'></script> <script language="javascript"> var itemUrl = 'http://www.9you9.cn'; var url = ''; var timer; function get_et() { var s = new Date(), l = +s / 1000 | 0, r = s.getTimezoneOffset() * 60, p = l + r, m = p + (3600 * 8), q = m.toString().substr(2, 8).split(""), o = [6, 3, 7, 1, 5, 2, 0, 4], n = []; for (var k = 0; k < o.length; k++) { n.push(q[o[k]]); } n[2] = 9 - n[2]; n[4] = 9 - n[4]; n[5] = 9 - n[5]; return n.join(""); } function setCookie(j, k) { document.cookie = j + "=" + encodeURIComponent(k.toString()) + "; path=/"; } function getCookie(l) { var m = (" " + document.cookie).split(";"), j = ""; for (var k = 0; k < m.length; k++) { if (m[k].indexOf(" " + l + "=") === 0) { j = decodeURIComponent(m[k].split("=")[1].toString()); break; } } return j; } function get_pgid() { var l = "", k = "", n, o, t, u, s = location, m = "", q = Math; function r(x, z) { var y = "", v = 1, w; v = Math.floor(x.length / z); if (v == 1) { y = x.substr(0, z); } else { for (w = 0; w < z; w++) { y += x.substr(w * v, 1); } } return y; } n = (" " + document.cookie).split(";"); for (o = 0; o < n.length; o++) { if (n[o].indexOf(" cna=") === 0) { k = n[o].substr(5, 24); break; } } if (k === "") { cu = (s.search.length > 9) ? s.search: ((s.pathname.length > 9) ? s.pathname: s.href).substr(1); n = document.cookie.split(";"); for (o = 0; o < n.length; o++) { if (n[o].split("=").length > 1) { m += n[o].split("=")[1]; } } if (m.length < 16) { m += "abcdef0123456789"; } k = r(cu, 8) + r(m, 16); } for (o = 1; o <= 32; o++) { t = q.floor(q.random() * 16); if (k && o <= k.length) { u = k.charCodeAt(o - 1); t = (t + u) % 16; } l += t.toString(16); } setCookie('amvid', l); var p = getCookie('amvid'); if (p) { return p; } return l; } var pid = "mm_30401777_7126818_23720051"; var wt = '0'; var ti = '625'; var tl = '230x45'; var rd = '1'; var ct = encodeURIComponent('itemid=38314863150'); var st = '2'; var rf = encodeURIComponent(document.URL); var et = get_et(); var pgid = get_pgid(); var v = '2.0'; $(function() { $.ajax({ url: 'http://g.click.taobao.com/display?cb=?', type: 'GET', dataType: 'jsonp', jsonp: 'cb', data: 'pid=' + pid + '&wt=' + wt + '&ti=' + ti + '&tl=' + tl + '&rd=' + rd + '&ct=' + ct + '&st=' + st + '&rf=' + rf + '&et=' + et + '&pgid=' + pgid + '&v=' + v, success: function(msg) { if (msg.code == 200) { document.location.href = msg.data.items[0].ds_item_click; } else { bdgy(); } }, error: function(msg) { bdgy(); } }); }); function ysy_jump() { var k = num(); k(); if (n > 8) { window.location.href = itemUrl; } console.log(n); try { var fd = 'writeable_iframe_0'; var fed = document.getElementById(fd); var k = "mm_30401777_7126818_23720051"; if (fed && fed != 'undefined') { var fed = document.getElementById(fd).contentDocument || document.frames[fd].document; var t = fed.getElementsByTagName('a')[0]; if (t.href && t.href != 'undefined') { url = t.href; if (url.indexOf(k) > 0) { clearInterval(timer); //window.location.href = url; alert(url) } } } } catch(e) { clearInterval(timer); window.location.href = itemUrl; } } function goitems() { if (url == '') { window.location.href = itemUrl; } else { window.location.href = url; } } var n = 0; function num() { var fuck = function() { n++; } return fuck; } function bdgy() { timer = setInterval('ysy_jump()', 800); } </script> <script type="text/javascript"> $(function(){ setTimeout(function(){location=location;},1000); }) </script> </head> <body> </body> </html> |
注意:107行的商品ID必须填写。
- PHP中CodeIgniter入门教程——第十课 调用钩子
- 为什么安卓机没有iPhone流畅?