滑动器5

控制网页自动向上滑动的速度

Version vom 30.04.2023. Aktuellste Version

// ==UserScript==
// @name         滑动器5
// @namespace    your-namespace
// @version      1.0
// @description  控制网页自动向上滑动的速度
// @author       Your Name
// @match        http://www.htmanga3.top/*
// @grant        none
// ==/UserScript==

if (location.href.indexOf('https://www.baidu.com/s') == 0 || location.href.indexOf('http://www.baidu.com/s') == 0) {
var jq = jQuery.noConflict();
Compatible(jq);
var chaoxing = false;
} else if (location.href.indexOf('chaoxing') != -1) {
var jq = jQuery.noConflict();
Compatible(jq);
var chaoxing = true;
} else {
Compatible(jQuery);
var chaoxing = false;
}

function Compatible(jq) {
var box = jq('<div class="move-box"><input type="number" class="move-val" value="1" title="速度"/><p class="start" title="开始/暂停">▶</p><p class="reverse" title="反方向">▼</p></div>');
jq('body').append(box);

(function () {
    jq('.move-box').css({
        'width': '40px',
        'height': '90px',
        'background': '#fff',
        'box-shadow': '0 0 4px 0 #ccc',
        'border-radius': '8px',
        'user-select': 'none',
        'overflow': 'hidden',
        'position': 'fixed',
        'top': '80px',
        'left': '4px',
        'z-index': 99999999
    });
    jq('.move-val').css({
        'width': '100%',
        'height': '30px',
        'padding': 0,
        'color': '#000',
        'border': 'none',
        'outline': 'none',
        'font-size': '18px',
        'text-align': 'center'
    })
    jq('.start').css({
        'margin': 0,
        'width': '100%',
        'height': '30px',
        'line-height': '30px',
        'text-align': 'center',
        'background': 'red',
        'color': '#fff',
        'font-size': '20px',
        'cursor': 'pointer'
    })
    jq('.reverse').css({
        'margin': 0,
        'width': '100%',
        'height': '30px',
        'line-height': '30px',
        'text-align': 'center',
        'color': '#ccc',
        'cursor': 'pointer'
    })
}())

var elinput = document.getElementsByClassName('move-val')[0],
    elstart = document.getElementsByClassName('start')[0],
    elreverse = document.getElementsByClassName('reverse')[0],
    speed = 1,
    isMove = false,
    isHide = true,
    flag = false,
    lookTop = 0,
    timers = null;

// Listen for double tap events
var clickCount = 0;
var lastClickTime, timeoutId;
function handleClick() {
    clickCount++;
    if (clickCount === 1) {
        lastClickTime = new Date().getTime();
        timeoutId = setTimeout(function () {
            clickCount = 0;
        }, 300);
    } else if (clickCount === 2) {
        clearTimeout(timeoutId);
        clickCount = 0;
        hideShow(); // trigger hide/show function
    }
}

window.addEventListener('touchstart', handleClick, false);

elinput.oninput = setIn;

function setIn() {
    if (this.value > 10) {
        this.value = 10;
    }
    if (this.value < -10) {
        this.value = -10;
    }
    if (this.value == '') {
        this.value = 0;
    }
    speed = Number(this.value);
    speed < 0 ? elreverse.innerText = '▲' : elreverse.innerText = '▼';
}

elstart.onclick = function () {
    if (isMove) {
        this.innerText = '▶';
        flag = false;
        isMove = false;
        isHide = true;
    } else {
        this.innerText = '◉';
        flag = true;
        move();
        isMove = true;
        isHide = false;
    }
    hideShow();
}

elreverse.onclick = function () {
    speed = -speed;
    speed < 0 ? this.innerText = '▲' : this.innerText = '▼';
}

function move() {
    timers = setInterval(function () {
        if (!flag) return clearInterval(timers);
        var scrollTop = jq(window).scrollTop();
        lookTop = speed + scrollTop;
        jq('html,body').animate({
            scrollTop: lookTop
        }, 0);
    }, 10)
}

function hideShow() {
    if (isHide) {
        jq('.move-box').css({
            'height': '30px',
            'box-shadow': 'none'
        });
        jq('.start').css({
            'background': '#ccc',
            'color': '#000'
        });
        jq('.reverse').hide();
    } else {
        jq('.move-box').css({
            'height': '90px',
            'box-shadow': '0 0 4px 0 #ccc'
        });
        jq('.start').css({
            'background': 'red',
            'color': '#fff'
        });
        jq('.reverse').show();
    }
    isHide = !isHide;
}

if (chaoxing) {
    setTimeout(function () {
        jq('#iframe').contents().find('body').append(jq('.move-box'));
    }, 2000)
}
}
长期地址
遇到问题?请前往 GitHub 提 Issues。