动漫之家跳转到手机版漫画页面

在漫画浏览页面的左下角添加一个按钮,单击之后跳转到手机版的相应页面

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         动漫之家跳转到手机版漫画页面
// @namespace    https://liu233w.com/dmzj-go-mobile
// @version      0.2
// @description  在漫画浏览页面的左下角添加一个按钮,单击之后跳转到手机版的相应页面
// @author       Liu233w
// @match        http://manhua.dmzj.com/*
// @grant        none
// @license      BSD 3-Clause License
// ==/UserScript==

(function () {
    'use strict';
    console.log('run')

    function gotoMobile() {
        const l = window.location
        window.location = 'https://m.dmzj.com/view' + l.pathname.replace('.shtml', '.html')
    }

    const btn = document.createElement('button')
    btn.innerHTML = '切换到手机版'
    btn.onclick = gotoMobile
    btn.style.position = 'fixed'
    btn.style.bottom = '40px'
    btn.style.left = '40px'
    window.btn = btn

    let oldOnLoad = () => {}
    if (window.onload) {
        oldOnLoad = window.onload
    }
    window.onload = () => {
        console.log('ready')
        document.querySelector('.footer').appendChild(btn)
        oldOnLoad()
    }
})();