You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.1 KiB
103 lines
3.1 KiB
var iframe = document.createElement('iframe');
|
|
if (
|
|
document.domain === 'www.tokcoder.com' ||
|
|
document.domain === 'tokcoder.com'
|
|
) {
|
|
iframe.src = 'https://www.educoder.net/autologin.html?t=' + Date.now();
|
|
} else {
|
|
iframe.src = 'https://www.tokcoder.com/autologin.html?t=' + Date.now();
|
|
}
|
|
iframe.sandbox =
|
|
'allow-scripts allow-same-origin allow-top-navigation allow-forms allow-popups allow-pointer-lock allow-popups-to-escape-sandbox allow-presentation allow-top-navigation-by-user-activation';
|
|
iframe.allow = 'geolocation document-domain';
|
|
iframe.style.position = 'absolute';
|
|
iframe.style.top = '-1000px';
|
|
iframe.style.opacity = 0;
|
|
iframe.style.visibility = 'hidden';
|
|
iframe.style.zIndex = -1;
|
|
document.body.appendChild(iframe);
|
|
iframe.onload = function() {
|
|
iframe.contentWindow.postMessage(
|
|
{ type: 'cookie', data: document.cookie },
|
|
'*',
|
|
);
|
|
};
|
|
|
|
|
|
window.gtag = new Function;
|
|
function setTop() {
|
|
if ((location.host.indexOf("ilearning") > -1 || location.host.indexOf("i-learning") > -1) && location.pathname.indexOf("/tasks") === -1) {
|
|
document.getElementById("root").style.paddingTop = "60px"
|
|
}
|
|
// saia默认进入竞赛
|
|
if(document.domain === "saia.educoder.net" && location.pathname === "/"){
|
|
location.href = "/competitions/shszyjnds-2023/list"
|
|
}
|
|
}
|
|
// window.addEventListener('popstate', function () {
|
|
// setTop();
|
|
// })
|
|
setTop();
|
|
|
|
const _historyWrap = function(type) {
|
|
const orig = history[type];
|
|
const e = new Event(type);
|
|
return function() {
|
|
const rv = orig.apply(this, arguments);
|
|
e.arguments = arguments;
|
|
window.dispatchEvent(e);
|
|
return rv;
|
|
};
|
|
};
|
|
history.pushState = _historyWrap('pushState');
|
|
history.replaceState = _historyWrap('replaceState');
|
|
|
|
window.addEventListener('pushState', function(e) {
|
|
setTop();
|
|
});
|
|
window.addEventListener('replaceState', function(e) {
|
|
setTop();
|
|
});
|
|
if (window.ENV !== 'dev') {
|
|
console.log = new Function;
|
|
}
|
|
function IEVersion() {
|
|
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
|
|
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
|
|
var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
|
|
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
|
|
if (isIE || isIE11) {
|
|
window.location.replace('/upgrade-browser.html');
|
|
}
|
|
}
|
|
IEVersion();
|
|
|
|
function getChromeVersion() {
|
|
var arr = navigator.userAgent.split(' ');
|
|
var chromeVersion = '';
|
|
for (var i = 0; i < arr.length; i++) {
|
|
if (/chrome/i.test(arr[i]))
|
|
chromeVersion = arr[i]
|
|
}
|
|
if (chromeVersion) {
|
|
return Number(chromeVersion.split('/')[1].split('.')[0]);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
if (getChromeVersion()) {
|
|
var version = getChromeVersion();
|
|
if (!!version && version < 70) {
|
|
window.location.replace('/upgrade-browser.html');
|
|
}
|
|
}
|
|
|
|
|
|
window.addEventListener("storage", function (e) {
|
|
if(e.key === "loginOut"){
|
|
if(this.location.pathname.indexOf("/exercise") > -1 && this.location.pathname.indexOf("/users") > -1 )
|
|
window.location.href = "/"
|
|
else
|
|
window.location.reload();
|
|
}
|
|
}) |