本WIKI于2021年03月04日通过了时雨音的接管申请,编辑权限开放。

欢迎收藏本WIKI防止迷路,也希望有爱的小伙伴和我们一起编辑哟~

建议使用PC版页面访问本WIKI以获得更佳体验!

编辑帮助WIKI建议加入我们使用哔哩哔哩APP打开WIKI

全站通知:

用户:646195980/WeiXinMP.js

来自坎特伯雷公主与骑士唤醒冠军之剑的奇幻冒险WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
/**
 * WeiXinMP.js | Inspiration comes from https://wiki.biligame.com/gt/?curid=26709
 * Author: 飞小RAN (https://wiki.biligame.com/gt/User:646195980)
 * License: See https://wiki.biligame.com/gt/User:646195980#License
 * 懒得搬公众号。
 **/
(async function() {
    'use strict';
    try {
        // 1. 获取内容
        const mp = document.querySelector('.weixinmp');
        const response = await fetch(`https://eo.hitfun.top/weixinmp/${mp.dataset.num}`);
        if (!response.ok) throw new Error(`[WeiXinMP] ${response.status}`);
        const html = await response.text();
        // 2. 解析 HTML
        const parser = new DOMParser();
        const doc = await parser.parseFromString(html, 'text/html');
        const xmp = doc.querySelector('#js_content');
        let content = await parser.parseFromString(xmp.innerHTML, 'text/html');
        // 3. 处理图片
        let imgs = content.querySelectorAll('img');
        imgs.forEach(i => {
            i.removeAttribute('width');
            i.removeAttribute('height');
            if (i.dataset.src.startsWith('https://mmbiz.qpic.cn')) {
                i.src = i.dataset.src.replace('https://mmbiz.qpic.cn/', 'https://eo.hitfun.top/mmbiz/');
            }
        });
        let sections = content.querySelectorAll('section');
        sections.forEach(i => {
            if (i.style.backgroundImage.startsWith('url')) {
                i.style.backgroundImage = '';//i.style.backgroundImage.replace('https://mmbiz.qpic.cn/', 'https://eo.hitfun.top/mmbiz/');
            }
        });
        // 4. 替换内容
        mp.innerHTML = content.querySelector('body').innerHTML;
        console.log('[WeiXinMP] 成功加载!');
    } catch (error) {
        console.error('[WeiXinMP] 处理失败:', error);
    }
})();