摸鱼神器-网页图片控制

打工都是人上人

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         摸鱼神器-网页图片控制
// @namespace    http://tampermonkey.net/
// @version      0.14
// @description  打工都是人上人
// @author       csj
// @match       *
// @include     *
// @grant        none
// @require  https://code.jquery.com/jquery-1.12.4.min.js
// ==/UserScript==
(function() {
    'use strict';

    start()
    var defaultType = true
    var defaultWidth = '50px'
    //图片缩小或放大
    function strongImg(type){
        let imgs = $('img')
        for(let i=0;i<imgs.length;i++){
            const item = imgs[i]
            if((item.offsetHeight < 100 || item.offsetWidth < 100) && type){
                continue;
            }
            item.style.width = type ? defaultWidth : ""
            item.style.height = type ? defaultWidth : ""
        }
        type ? defaultWidth = '50px' : defaultWidth = ''
        console.log(type ? "缩小成功" : "放大成功")
    }

    //控制单个图片
    function controlOne(){
        let imgs = $('img')
        for(let i=0;i<imgs.length;i++){
            const item = imgs[i]
            if(item.offsetHeight < 100 || item.offsetWidth < 100){
                continue;
            }
            $(item).mouseout(function(){
                const img = this
                img.style.width = defaultWidth
                img.style.height = defaultWidth
            })
            $(item).mouseover(function(){
                const img = this
                img.style.width = ''
                img.style.height = ''
            })
        }
    }

    //添加控制按钮
    function start(){
        const button = "<button id='injectStrongImg' style='position: fixed;left: 10px;top: 10px;border: none;z-index: 99999;'>注入</button>"
        $('body').prepend(button)
        $('button#injectStrongImg').click(function(){
            //单个图片绑定单击事件控制
            controlOne()
            strongImg(defaultType);
            defaultType = !defaultType
        })
    }

    //测试更新



})();