avgle 过滤低评分

avgle 过滤低评分,自动记录音量

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         avgle 过滤低评分
// @namespace    http://tampermonkey.net/
// @version      1.4.1
// @description  avgle 过滤低评分,自动记录音量
// @author       en20
// @match        *://*.avgle.com/*
// @grant        none
// @run-at document-idle
// ==/UserScript==

;(function () {
    // 移除低评分
    function removeMinRating() {


        // 每个视频框
        let $avList = $('.row .col-sm-4,.col-sm-6 ')

        // console.log($avList.length, $avList)
        for (let i = 0; i < $avList.length; i++) {

            // 去掉低评分
            let rating = $(".video-rating", $avList[i]).text().replace(/ /g, "").replace(/%/g, "")
            // console.log('rating',rating,(parseInt(rating) || 0) , window.minRating,(parseInt(rating) || 0) < window.minRating)
            if ((parseInt(rating) || 0) < window.minRating) {
                $avList[i].remove()
            }
        }
    }

    // 设置音量
    function setVolume() {
        let videoEle = document.querySelector('#video-player_html5_api')
        let savedVolume = localStorage.getItem('avgleVolume') || .2
        if (videoEle) {

            videoEle.volume = savedVolume
        }


    }

    // 自动记录音量
    function addVolumeChangeListener() {
        let videoEle = document.querySelector('#video-player_html5_api')


        videoEle && videoEle.addEventListener('volumechange', (e) => {
            let volume = e.target.volume

            localStorage.setItem('avgleVolume', volume)
        })
    }


    function controlPanel() {

        let style = `
.panel{
    position: fixed;
    top: 250px;
    left: 45px;
    border: 1px cadetblue solid !important;
    padding: 20px 10px;
}
        `
        let panel = `
        <div class='panel'>

        <input type='text' id='minRatingInput' >
        <button onclick='btnReset()'>重置</button>
</div>
        `
            $('body').append($(panel)),
            $('body').append($("<style></style>").html(style))

    }


    let minRating = localStorage.getItem('avgleMinRating')

    // 最低评分
    window.minRating = minRating || 78
    window.btnReset = function () {
        let inputVal = $('#minRatingInput')[0].value
        localStorage.setItem('avgleMinRating', parseInt(inputVal) || window.minRating)
        window.location.reload()
    }
    controlPanel()
    $('#minRatingInput')[0].setAttribute('placeholder', window.minRating)
    $('#minRatingInput').bind('keypress', function (event) {
        if (event.keyCode === 13) {
            window.btnReset()
        }
    })
    removeMinRating()
    setVolume()
    addVolumeChangeListener()

})()