Greasy Fork is available in English.

B站点赞姬

不白嫖,为观看时间超过10s的视频自动点赞

// ==UserScript==
// @name         B站点赞姬
// @namespace    http://tampermonkey.net/
// @version      1.11
// @description  不白嫖,为观看时间超过10s的视频自动点赞
// @author       kakasearch
// @match        https://www.bilibili.com/*
// @icon         data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPg0KPHN2ZyB3aWR0aD0iODAwcHQiIGhlaWdodD0iODAwcHQiIHZpZXdCb3g9IjAgMCA4MDAgODAwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+DQo8ZyBpZD0iI2ZmN2YwMmZmIj4NCjxwYXRoIGZpbGw9IiNmZjdmMDIiIG9wYWNpdHk9IjEuMDAiIGQ9IiBNIDUzNi42OCAxNTYuMDYgQyA1MzYuODQgMTQ2Ljk3IDU0Mi4yNyAxMzguMTIgNTUwLjkyIDEzNC44NiBDIDU1Mi44NSAxNDMuODYgNTU0LjcyIDE1Mi44NyA1NTYuNjAgMTYxLjg3IEMgNTU3LjA2IDE2NS4yOSA1NTkuNTcgMTY3LjgxIDU2MS4zNiAxNzAuNTkgQyA1NzMuNjcgMTY5LjYzIDU4Ni41NCAxNzEuMzUgNTk3LjM0IDE3Ny42NSBDIDYwOC41MyAxODQuMDUgNjE2Ljk0IDE5NC44MSA2MjEuMjIgMjA2LjkwIEMgNjI2LjEyIDIxNy4wOCA2MzcuMjAgMjIzLjUyIDYzOS41NiAyMzUuMDUgQyA2MzcuNjIgMjQ3LjIzIDYzNS40OCAyNTkuOTggNjI4LjUyIDI3MC40NSBDIDYyMi40NCAyNzkuNjMgNjEyLjA3I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Qo8L3N2Zz4NCg==
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at        document-end
// ==/UserScript==

(function() {
    'use strict';
    function fireKeyEvent(el, evtType, keyCode){
        //参考自 https://blog.csdn.net/lovelyelfpop/article/details/52471878
        var doc = el.ownerDocument,
            win = doc.defaultView || doc.parentWindow,
            evtObj;
        if(doc.createEvent){
            if(win.KeyEvent) {
                evtObj = doc.createEvent('KeyEvents');
                evtObj.initKeyEvent( evtType, true, true, win, false, false, false, false, keyCode, 0 );
            }
            else {
                evtObj = doc.createEvent('UIEvents');
                Object.defineProperty(evtObj, 'keyCode', {
                    get : function() { return this.keyCodeVal; }
                });
                Object.defineProperty(evtObj, 'which', {
                    get : function() { return this.keyCodeVal; }
                });
                evtObj.initUIEvent( evtType, true, true, win, 1 );
                evtObj.keyCodeVal = keyCode;
                if (evtObj.keyCode !== keyCode) {
                    console.log("keyCode " + evtObj.keyCode + " 和 (" + evtObj.which + ") 不匹配");
                }
            }
            el.dispatchEvent(evtObj);
        }
        else if(doc.createEventObject){
            evtObj = doc.createEventObject();
            evtObj.keyCode = keyCode;
            el.fireEvent('on' + evtType, evtObj);
        }
    }
    function main(){
        console.log("准备点赞")
        let tmp = setInterval(function(){
            let video= document.querySelector("video")
            if(video){
                clearInterval(tmp)
                let bv = /BV[a-zA-Z0-9]+/.exec(window.location.href)[0]
                if(bv && GM_getValue(bv)){
                    console.log(bv,GM_getValue(bv))
                    console.log("之前点过赞")
                }else{
                    GM_setValue(bv,new Date().toLocaleString())
                    setTimeout(function(){
                        fireKeyEvent(window.document.body,"keydown",81)
                        fireKeyEvent(window.document.body,"keyup",81) //点击1次Q键,删除此行变为长按q,即三连
                        console.log("已点赞")},10000)
                }
            }
        },3000)

        }
    let obser = setInterval(
        function(){
            let video= document.querySelector("video")
            if(video){
                clearInterval(obser)
                main()
                let observer = new MutationObserver(main)
                observer.observe(video, { attributes: true,childList: true });//检测video变化,防止中途切p失效
            }

        },200
    )
    })();