SCO实验室文章重排

SCO实验室文章加宽,点击图片放大

// ==UserScript==
// @name         SCO实验室文章重排
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  SCO实验室文章加宽,点击图片放大
// @author       Mr.NullNull
// @match        https://www.seotest.cn/*.html
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function Main() {
        var dom = document.createElement("style");
        dom.innerHTML = `
        .lm_index {
            width: 1440px;
        }
        .lm_left {
            width: 1140px;
        }
        #my_img {
            margin: 0;
            padding: 0;
            outline: 8px solid #aaa;
            background: #aaa;
            
            position: fixed;
            top: 50%;
            left: 50%;
            z-index: 9999;
        }
        `;
        document.body.append(dom);


        dom = document.createElement("div");
        dom.id = "my_img";
        dom.style = "display: none;"
        dom.innerHTML = `<img src="">`;
        document.body.append(dom);

        var domdiv = document.querySelector("#my_img");
        var domimg = document.querySelector("#my_img > img");

        document.addEventListener("click", function (event) {
            var ev = event ? event : window.event;
            var elem = ev.target;

            if (elem.tagName.toLowerCase() == 'img') {
                var w = elem.naturalWidth;
                var h = elem.naturalHeight;
                console.log(w, h);
                console.log(elem.src);

                var styleTxt = `
                    margin-top: -${h/2}px;
                    margin-left:-${w/2}px;
                `;

                domdiv.style = styleTxt;
                domimg.src = elem.src;

            } else {
                dom.style = "display: none;";
            }


        }, true);

        domdiv.onclick = function () {
            dom.style = "display: none;";
        };

    }

    Main();
})();