122 lines
4.1 KiB
JavaScript
122 lines
4.1 KiB
JavaScript
(function () {
|
|
const currentURL = window.location.href;
|
|
const url = new URL(currentURL);
|
|
|
|
// 获取所有URL参数,用于传递给目标页面
|
|
const allParams = new URLSearchParams(url.search);
|
|
|
|
// 构建带参数的目标URL函数
|
|
function buildTargetUrl(baseUrl) {
|
|
try {
|
|
const targetUrl = new URL(baseUrl);
|
|
// 将当前页面的所有参数添加到目标URL中(除了jwid和key,避免冲突)
|
|
for (const [key, value] of allParams) {
|
|
if (key !== 'key') {
|
|
targetUrl.searchParams.set(key, value);
|
|
}
|
|
}
|
|
return targetUrl.toString();
|
|
} catch (e) {
|
|
// 如果目标URL格式不正确,返回原始URL
|
|
|
|
return baseUrl;
|
|
}
|
|
}
|
|
|
|
// Main processing function
|
|
async function processLinkData(res) {
|
|
const app = document.getElementById('app');
|
|
|
|
const platform = res.platform || 'douyin';
|
|
|
|
const jump_gif = 'https://oss.yqbmb.com/card/v1/' + platform + '.gif';
|
|
|
|
// 1. 设置 favicon
|
|
const favicon = document.createElement('link');
|
|
favicon.rel = 'shortcut icon';
|
|
favicon.href = res.icon;
|
|
document.head.appendChild(favicon);
|
|
|
|
// 2. 设置 desc
|
|
const desc = document.createElement('meta');
|
|
desc.name = 'description';
|
|
desc.content = res.desc || '';
|
|
document.head.appendChild(desc);
|
|
|
|
// 3. 设置 title
|
|
document.title = res.title;
|
|
|
|
// 构建带参数的目标URL
|
|
const targetUrlWithParams = buildTargetUrl(res.url);
|
|
// const targetUrlWithParams = res.url;
|
|
|
|
// 以下域名的目标地址不使用iframe内嵌模式
|
|
const jw_url_arr = ['work.weixin.qq.com', 'weixin://', 'www.iesdouyin.com', 'v.douyin.com'];
|
|
let noiframe = jw_url_arr.some(sub => res.url.includes(sub));
|
|
if (res.url.includes('mp.weixin.qq.com')) {
|
|
noiframe = false;
|
|
}
|
|
|
|
if (noiframe) {
|
|
app.innerHTML = `
|
|
<div class="ssl_tips_container">
|
|
<div class="ssl_tips">
|
|
<span class="ssl_logo"></span>
|
|
<span class="ssl_text">本页面已启用SSL安全加密</span>
|
|
</div>
|
|
</div>
|
|
<div class="jump_gif"><img src="${jump_gif}" /></div>
|
|
<div class="jump_text">正在自动跳转...</div>
|
|
<div class="jump_button_tips">如没有自动跳转请点击按钮</div>
|
|
<a href="${targetUrlWithParams}" class="a-jump">
|
|
<div class="jump_button">点击跳转</div>
|
|
</a>
|
|
<div class="powerby"></div>
|
|
<iframe src="${targetUrlWithParams}" style="opacity:0;"></iframe>
|
|
`;
|
|
} else {
|
|
app.innerHTML = `
|
|
<iframe src="${targetUrlWithParams}" allowfullscreen style="width: 100%;height: 100vh;border: none;"></iframe>
|
|
`;
|
|
}
|
|
|
|
if (res.url.includes('www.iesdouyin.com') || res.url.includes('mp.weixin.qq.com')) {
|
|
location.href = targetUrlWithParams;
|
|
}
|
|
|
|
// Safari、微信环境自动跳转
|
|
if (isSafari()) location.href = targetUrlWithParams;
|
|
if (isWeChat() && res.url.includes('work.weixin.qq.com')) location.href = targetUrlWithParams;
|
|
}
|
|
|
|
// Use data from landing.js to avoid duplicate request
|
|
processLinkData(window.LANDING_CONFIG);
|
|
|
|
// 显示状态消息页面
|
|
function showStatusMessage(message) {
|
|
const app = document.getElementById('app');
|
|
if (app) {
|
|
app.innerHTML = `<div class="icon"></div><p class="error">${message}</p>`;
|
|
}
|
|
}
|
|
|
|
// Safari环境检测
|
|
function isSafari() {
|
|
const ua = navigator.userAgent.toLowerCase();
|
|
return ua.includes('safari') && !ua.includes('chrome');
|
|
}
|
|
|
|
// 微信环境检测
|
|
function isWeChat() {
|
|
return /MicroMessenger/i.test(navigator.userAgent);
|
|
}
|
|
|
|
// 微信环境隐藏右上角菜单
|
|
// 如果不需要隐藏请将下方代码删除
|
|
document.addEventListener('WeixinJSBridgeReady', function () {
|
|
if (typeof WeixinJSBridge !== 'undefined') {
|
|
WeixinJSBridge.call('hideOptionMenu');
|
|
}
|
|
});
|
|
})();
|