Greasy Fork is available in English.

爱上ASMR - Plus

屏蔽词视频评论、收藏夹备注、评论区时间跳转、显示评分投票、标题封面完整显示、禁用动态头像

// ==UserScript==
// @name         爱上ASMR - Plus
// @namespace    https://www.asasmr.top/
// @version      5.5
// @description  屏蔽词视频评论、收藏夹备注、评论区时间跳转、显示评分投票、标题封面完整显示、禁用动态头像
// @author       真是一坨大的根本看不懂<( _ _ )>
// @include      /https?\:\/\/.*\.asasmr\d\.com\/.*/
// @match        http*://*.asasmr0.com/*
// @match        http*://*.aisasmr.com/*
// @match        http*://*.aisasmr.net/*
// @icon         https://asmrscj.com/assets/images/logos/as111.png
// @run-at       document-body
// @grant        GM_getValue
// @grant        GM_setValue
// @license      MIT
// @require      https://code.jquery.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

  // jquery
    const jqUrl = "https://code.jquery.com/jquery/3.4.1/jquery.min.js"

    function loadScript(url){
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = url;
        document.body.appendChild(script);
    }

    loadScript(jqUrl)


  // 初始化
    let notes = GM_getValue('notes', {});

    // 获取已存储的屏蔽词列表
    function getRegexList() {
        return GM_getValue('regexList', []);
    }

    // 设置新的屏蔽词列表
    function setRegexList(list) {
        GM_setValue('regexList', list);
    }

    // 备注GM
    function getNotes(id) {
        if (!notes[id]) {
            notes[id] = [];
        }
        return notes[id].join('\n');
    }

    function setNotes(id, value) {
        notes[id] = value.split('\n');
        GM_setValue('notes', notes);
    }

    // 自定义样式
    const styleElement = document.createElement('style');
    styleElement.textContent = `
  /* 备注 */
  .hmd-save-notes-button {float: right;margin-top: 20px;}
  .hmd-notes-area {width: 100%;padding: 8px;max-width: 75%;height: 60px;border: 1px solid rgb(204, 204, 204);font-size: 14px;color: rgb(51, 51, 51);}
  .archive-excerpt > p {height: 48px;}

  /* 音视频 */
  .daoyan.blcss,#breadcrumbs {display: none !important;}
  #section > li:nth-child(2) {display: none !important;}
  #single > div.content > div.sheader > div.data > div.sgeneros {display: none !important;}
  #aplload {background: #666;border: solid 2px #444;border-radius: 22px;color: #fff;padding: 2px 22px;font-weight: bold;}
  .testBtn-a {background: #666;}
  .timeauto {padding: 20px 10px;margin-bottom: 10px;}
  .starstruck-wrap {display: block;}
  #single > .content > .sheader > .data {margin: 0;width: auto;}
  #single > .content > .sheader > .poster {width: auto;padding-bottom: 8px;background: 0;}
  #single > .content > .sheader > .poster > img {max-width: 100%;width: auto;}
  #single > .content > .sheader {display: flex;flex-direction: column;}
  #info > .wp-content > a {padding-right: 8px;}

  /* 用户 */
  .user-dashboard-dropdown,.user-dashboard-dropdown.show {transition: all 0.2s ease-out;box-shadow: -2px 4px 12px 0 rgb(0 0 0 / 20%);;}
  .user-dashboard-dropdown ul {display: flex;flex-direction: column;align-items: center;justify-content: space-between;}
  .user-dashboard-dropdown ul li:first-child {height: 60px;}
  .user-dashboard-dropdown ul li:last-child {box-shadow: none;}
  .user-dashboard-dropdown ul li {width: 100%;height: 50px;display: flex;align-items: center;justify-content: center;position: relative;align-self: stretch;}
  .user-dashboard-dropdown a.top-my-home {background: 0;}
  .user-dashboard-dropdown a {border: 0 !important;align-items: center;display: flex;justify-content: center;}
  .user-dashboard-dropdown a i.asmr {position: absolute;left: 20px;}
  .user-dashboard-dropdown p span.top-user-link-des {display: none !important;}
  .iconk-tongzhi:before {zoom: 1.3;}
  .iconk-tongzhi {left: 15px !important;}
  .user-dashboard-dropdown > ul> li:nth-last-child(3) > a > i:before {content: "\u{e61f}";}
  /* 分割线 */
  .separator {height: 1px;align-self: stretch;margin: 5px 15px;background: rgba(0, 0, 0, 0.1);}


  /* 等级颜色 */
  .level-0,.level-1 {background: #C0C0C0;}
  .level-2 {background: #8BD29B;}
  .level-3 {background: #7BCDEF;}
  .level-4 {background: #FEBB8B;}
  .level-5 {background: #EE672A;}
  .level-6 {background: #F04C49;}
  .level-7 {background: #821CF9;}
  .level-8 {background: #dddddd;color: #000;}
  .level-admin {background: #FF1111;}
  .level {opacity: .8 !important;}


  /* 左侧栏 */
  .cban {text-align: center;position: fixed;top: 45%;left: 0;transform: translateY(-95%);font-family: asmr;z-index: 99999;}
  .cban i:before {
    content: "\u{e678}";
    cursor: pointer;
    display: flex;
    width: 40px;
    height: 40px;
    background-color: #fff;
    box-shadow: 0px 2px 6px 2px rgba(0, 0, 0, 0.26);
    position: absolute;
    border-radius: 20px;
    transition: all 0.2s;
    flex-direction: column;
    justify-content: center;
    transform: translateX(-120%);
  }

  .cban i {width: 60px;height: 60px;position: fixed;top: 45%;z-index: 1002;}
  .cban i:hover::before {transform: translateX(0%);transition: transform 0.3s ease-out, opacity 0.3s ease-out;}
  .mobile-nav.active {box-shadow: 2px 0px 12px 0px rgb(0 0 0 / 30%);}

  /* 屏蔽词 */
  #regex-input:focus {box-shadow: 0 0 0 1px #00a0d8, 0 0 0 3px #00a0d833;}

  #regex-input {
    padding: 4px 6px;
    margin: 0 0 10px 0;
    border-radius: 4px;
    outline: none !important;
    color: black;
    border: 1px solid rgba(136, 136, 136, 0.2666666667);
  }

  .pbcan {
    border: 1px solid #00000022;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    margin: 0 5px 0;
  }

  #regex-list > li {
    background-color: #eee;
    margin: 0 0 5px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid rgba(136, 136, 136, 0.2666666667);
  }

  #regex-list > li > span{padding: 0 6px;color: #000;}

  /* 顶栏 */
  .responsive .form-control:focus {border-color: #66afe9;box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);}
  .responsive .form-control {border-radius: 20px 0 0 20px;border-right: 0 !important;border: 1px solid #ccc;padding: 6px 12px;width: 40vw;}
  .responsive > #advc-menu > form > button {border-radius: 0 20px 20px 0;border: 1px solid #ccc;border-left: 1px solid #ddd;padding: 8px 12px 8px 8px;background-color: #fff;}
  .responsive .search a.search-resp:before {content: "\ue606"  !important;font-family: 'asmr' !important;}
  .responsive .search {padding: 14px 13px 11px 13px;}
  #form-search-resp {display:none !important;}

  .responsive .logo {display:none !important;}


  /* 底栏 */
  .touchy-search-button.touchy-toggle-search {display: none !important;}
  .touchy-by-bonfire-wrapper.mobile-show.touchy-menu-active {display: none !important;}


  /* 深色模式 */
  .dark .single_menu.sidblock {background: #232627;}
  .dark .sidemenu h1 a {color:#fff;}
  .dark .sidemenu .td-link-element-after .td-element-after,.dark .sidemenu .td-link-element-after {color:#fff !important;}
  .dark .hmd-blacklist {background: #222;}
  .dark .hmdclosebutton {background: #111;}
  .dark .hmd-notes-area {color: #bbb;background: #333;}
  body.dark::before {content: "";position: fixed;inset: 0;;background-color: rgba(0, 0, 0, 0.3);z-index: 9999;pointer-events: none;}
  .dark p#breadcrumbsmove {background: #292b2c;color: #bbb;display: block !important;border-bottom: 1px solid #666;}
  .dark p#breadcrumbsmove a {color: #888;}
  .dark .hmd-popup-content {background: #292b2c;color: #bbb;}
  .dark .cban i:before {background-color: #333;border: solid 1px #3f3f3f;}
  .dark .responsive > #advc-menu > form > button {background-color: #232627;border-color: #666;color: #aaa;}
  .dark .responsive .form-control {border-color: #666;color: #ccc !important;}
  .dark input::placeholder {color: #ccc !important;}


  /* 其他 */
  input::-webkit-outer-spin-button,input::-webkit-inner-spin-button {-webkit-appearance: none !important;margin: 0;}
  input[type="number"] {-moz-appearance: textfield;}
  /* 媒体卡片 */
  .iconk-play:before {content: "";}
  .iconk-yinpin3:before {content: "";}
  .poster:hover i.iconk-play:before {content: "\ue604";}
  .poster:hover i.iconk-yinpin3:before {content: "\ue60c";}

  body .module .content .items .item .poster .rating,body .fittobox .item .poster .rating {
    background: linear-gradient(180deg,transparent,rgba(0,0,0,.5) 99.32%) !important;
    height: 40px!important;position: absolute!important;padding-top: 18px!important;inset: auto 0 0 0!important;
  }
  body .item-in .rating span {color: #fff!important;}
  .vidtime {bottom: 5px;top: auto;background: 0 !important;}
  .quality {inset: 0 0 auto auto !important;border-radius: 0 0 0 5px !important;}
  .yz-project-text {display: flex;flex-direction: column;align-items: center;}

`;
    document.head.appendChild(styleElement);
// css end
// css end

    $('<div>').addClass('cban').append($('<i>').appendTo('body')).prependTo('body');


    function 什么玩意() {
      // 分割线
        const firstListItems = document.querySelectorAll('.user-dashboard-dropdown ul li:first-child');

        firstListItems.forEach((firstListItem) => {
            const separator = document.createElement('div');
            separator.classList.add('separator');
            firstListItem.insertAdjacentElement('afterend', separator);
        });

      // 左侧栏
        // 默认打开周热门
        $('#menu-item-22769 > a').attr('href', '/rmen?timeframe=week');
        var $srementargetElement = $('#arch-menu > div > div:nth-child(2) > ul > li:nth-child(4) > a');
        if ($srementargetElement.length) {
            $srementargetElement.attr('href', '/rmen?timeframe=week');
        }

        // 左侧栏展开按钮
        var cban = document.querySelector('.cban');
        var mobileNav = document.querySelector('.mobile-nav');
        var mobileoverlay = document.querySelector('.mobile-overlay');

        function toggleActiveClass() {
            mobileNav.classList.toggle('active');
            mobileoverlay.classList.toggle('active');
        }

        cban.addEventListener('click', toggleActiveClass);

        // 显示手机顶栏,为手机网页,则关闭左侧栏展开按钮
        var $header = $('#header');
        if ($header.css('display') === 'none') {
            $('.cban').hide();
        }

      // 顶栏
        var $qiandaolement = $('.responsive > .search > .search-resp');
        $qiandaolement.attr('href', window.location.origin + '/mission');

        // 创建搜索
        var $divElement = $('<div>')
            .attr('id', 'advc-menu')
            .addClass('searchs')
            .css({
                'float': 'left',
                'padding': '10px 0px 8px 5px'
            });

        // 搜索框
        var $formElement = $('<form>', {id: 'searchform',action: window.location.origin,method: 'get'}).css('display', 'flex');
        var $inputElement = $('<input>', {type: 'text',class: 'form-control',placeholder: '搜索...',name: 's',id: 's'}).val('');

        // 搜索按钮
        var $buttonElement = $('<button>').attr('type', 'submit');

        var $spanElement = $('<span>')
            .addClass('olam')
            .text('\uE73B')
            .css('font-family', "'olam' !important");

        $buttonElement.append($spanElement);
        $formElement.append($inputElement);
        $formElement.append($buttonElement);
        $divElement.append($formElement);
        $('.responsive').append($divElement);

       // 底栏
        // 底部"首页"
        var $homedibu = $('<a>', {href: window.location.origin,class: 'touchy-home-button'});
        var $homedibuspan = $('<span>', {class: 'touchy-call-text-label-offset'});
        var $homedibuicon = $('<i>', {class: 'fa fa-home'});
        var $homedibub = $('<b>').text('首页');

        $homedibuspan.append($homedibuicon);
        $homedibu.append($homedibuspan);
        $homedibu.append($homedibub);
        $('.touchy-search-button').after($homedibu);

        // 底部"菜单"
        var touchymenu = document.querySelector('.touchy-menu-button.touchy-toggle-menu');
        var newElement = touchymenu.cloneNode(true);
        touchymenu.parentNode.replaceChild(newElement, touchymenu);

        newElement.addEventListener('click', function() {
            mobileoverlay.classList.toggle('active');
            mobileNav.classList.toggle('active');
        });


    }


    // 简介
    function 简介() {
        // 简介封面
        const $dateSpan = $('#single > .content > .sheader > .data > .extra > .date');
        $dateSpan.after('<br><br>');

        // 完整封面
        const ogImageMeta = $('meta[property="og:image"]').attr('content') || '';

        // 替换图片链接
        const $dplayerVideo = $('#single > .content > .sheader > .poster > img');
        if ($dplayerVideo.length && ogImageMeta) {
            $dplayerVideo.attr('src', ogImageMeta);
        }

      // youtube超链接
        const paragraphs = document.querySelectorAll('.wp-content p');

        paragraphs.forEach((p) => {
            if (p.textContent.includes('油管:')) {
                // 匹配"油管:"后面的所有视频ID
                const regex = /油管:([\w-]+(?:\s+[\w-]+)*)/g;
                const newContent = p.textContent.replace(regex, (match, videoIds) => {
                    const ids = videoIds.split(/\s+/).filter(id => id.trim() !== '');
                    const replacements = ids.map(videoId => `油管:<a href="https://www.youtube.com/watch?v=${videoId}" target="_blank">${videoId}</a>`);
                    return replacements.join(' ').trim();
                });

                p.innerHTML = newContent;
            }
        });

    }


  // 视频功能
    // 评论区时间跳转
    function 时间跳转() {
        const paragraphs = document.querySelectorAll('.wc-comment-right > .wc-comment-text > p');

        paragraphs.forEach((p) => {
            const regex = /([0-9]|[1-9][0-9])[::;;.。分]([0-5][0-9])/g;

            p.innerHTML = p.innerHTML.replace(regex, (match) => {
                const [hours, minutes] = match.split(/[::;;.。分]/);
                const totalSeconds = parseInt(hours) * 60 + parseInt(minutes);
                return `<a href="javascript:dp.seek(${totalSeconds});">${match}</a>`;
            });
        });

        // 将视图定位到 播放器
        const linkElements = document.querySelectorAll('.wc-comment-right > .wc-comment-text > p > a');

        linkElements.forEach((linkElement) => {
            linkElement.addEventListener('click', () => {
                const dplayerElement = document.querySelector('#dplayer');

                window.scrollTo({
                    top: dplayerElement.offsetTop,
                    behavior: 'smooth' // 可以选择平滑滚动效果
                });
            });
        });
    }


  // 禁用动态头像
    function 替换动态头像() {
        const images = document.querySelectorAll('#wcThreadWrapper img');
            images.forEach(image => {
                if (image.src.includes('.gif')) {
                    const fileName = image.src.split('/').pop();
                    const letters = 'abcdefghijklmnopqrstuvwxyz';
                    const randomLetter = letters[Math.floor(Math.random() * letters.length)];
                    const newSrc = window.location.origin + `/wp-content/plugins/wp-first-letter-avatar/images/default/96/latin_${randomLetter}.png`;
                    image.src = newSrc;
                }
            });
    }


    // 创建一个区域供用户输入屏蔽词
    function 创建屏蔽词区域() {
        const $sidemenu = $('.sidemenu:last');
        const $container = $('<div>', { id: 'blocker-controls', class: 'sidemenu' });
        const $label = $('<h2>', { for: 'regex-input', text: '屏蔽词' });
        const $input = $('<input>', { type: 'text', id: 'regex-input', placeholder: '支持正则表达式' });
        const $addButton = $('<button>', { id: 'add-regex', text: '添加', class: 'pbcan' });
        const $regexList = $('<ul>', { id: 'regex-list' });

        $container.append($label, $input, $addButton, $regexList);
        $sidemenu.append($container);

        $addButton.on('click', function () {
            const regexStr = $input.val().trim();
            if (regexStr) {
                addRegex(regexStr);
                $input.val('');
            }
        });
    }


    // 添加新的屏蔽词到列表
    function addRegex(regexStr) {
        let regexList = getRegexList();
        try {
            new RegExp(regexStr);
            if (!regexList.includes(regexStr)) {
                regexList.push(regexStr);
                setRegexList(regexList);
                渲染屏蔽词列表();
            }
        } catch (error) {
            console.error("Invalid regular expression: ", regexStr);
            alert("请输入有效的正则表达式");
        }
    }


    // 删除指定的屏蔽词
    function removeRegex(index) {
        let regexList = getRegexList();
        regexList.splice(index, 1);
        setRegexList(regexList);
        渲染屏蔽词列表();
    }

    // 显示屏蔽词列表
    function 渲染屏蔽词列表() {
        const regexList = getRegexList();
        const regexListElement = document.getElementById('regex-list');
        regexListElement.innerHTML = '';

        regexList.forEach((regexStr, index) => {
            const listItem = document.createElement('li');
            const span = document.createElement('span');
            const button = document.createElement('button');

            span.textContent = regexStr;
            button.className = 'pbcan';
            button.textContent = '删除';
            button.addEventListener('click', function () {
                removeRegex(index);
            });

            listItem.appendChild(span);
            listItem.appendChild(button);
            regexListElement.appendChild(listItem);
        });
    }

    // 检查文本是否应该被屏蔽
    function isBlocked(text) {
        const regexList = getRegexList();
        return regexList.some(regexStr => {
            try {
                const pattern = new RegExp(regexStr.replace(/^\/|\/g?i?m?$/, ''), 'gi');
                return pattern.test(text);
            } catch (error) {
                console.error(`Invalid regular expression: ${regexStr}`, error);
                return false;
            }
        });
    }

    function 屏蔽带屏蔽词的评论() {
        const commentTexts = document.querySelectorAll('.wc-comment-text > p');

        commentTexts.forEach(commentText => {
            //console.log(commentText.textContent); // 输出每个评论的文本内容
            const parentElement = commentText.parentElement.parentElement.parentElement;
            if (isBlocked(commentText.textContent)) {
                console.log('%cBlocking:', 'color: #f33;', commentText.textContent); // 输出被屏蔽的评论内容
                parentElement.style.display = 'none';
            } else {
                parentElement.style.display = '';
            }
        });
    }

  // 加载更多评论后执行相关函数
    function 加载更多评论相关函数() {
        const threadWrapper = document.getElementById('wcThreadWrapper');
        const observer = new MutationObserver(mutations => {
            mutations.forEach(mutation => {
                if (mutation.type === 'childList') {
                    渲染屏蔽词列表();
                    屏蔽带屏蔽词的评论();
                    替换动态头像();
                    时间跳转();
                }
            });
        });

        if (threadWrapper instanceof Node) {
            observer.observe(threadWrapper, { childList: true });
            console.log('%c可以执行评论相关函数', 'color: white; background-color: #4CAF50; padding: 10px; font-size: 16px;');
        } else {
            console.log('%c评论相关函数不可执行', 'color: white; background-color: #f33; padding: 10px; font-size: 16px;');
        }
    }

    function 备注() {
        console.log('媒体页执行一切正常!');
      // 添加备注区域
        const archiveContainers = document.querySelectorAll('#author-page .archive');
        archiveContainers.forEach(container => {
            const articleLink = container.querySelector('article > a');
            const noteid = articleLink.href.match(/\/(video|sound)\/([\w-]+\.html)/)[0];// 提取ID
            const notesArea = document.createElement('textarea');
            notesArea.classList.add('hmd-notes-area');
            notesArea.placeholder = '添加备注';
            notesArea.value = getNotes(noteid) || '';

            notesArea.addEventListener('input', () => {
                setNotes(noteid, notesArea.value);
            });

            const saveNotesButton = document.createElement('button');
            saveNotesButton.textContent = '保存备注';
            saveNotesButton.classList.add('hmd-save-notes-button');
            saveNotesButton.addEventListener('click', () => {
                setNotes(noteid, notesArea.value);
                alert('备注已保存!');
            });

            container.appendChild(notesArea);
            container.appendChild(saveNotesButton);
        });
    }




    // 页面加载完毕时执行一次
    window.onload = function() {

      // 媒体页
        if (window.location.href.match(/https:\/\/.*\/(video|sound)\/(\d+)\.html.*/)) {
            加载更多评论相关函数();
            创建屏蔽词区域();
            渲染屏蔽词列表();
            屏蔽带屏蔽词的评论();
            简介();
            替换动态头像();
            时间跳转();
            setTimeout(function() {
                console.log('%c媒体页执行一切正常!', 'color: white; background-color: #4CAF50; padding: 10px; font-size: 16px;');
            }, 1000);
        }

      // 收藏页
        if (window.location.href.match(/^https:\/\/.*\/author\//) && window.location.href.match(/\?tab=collect.*/)) {
            备注();
        }

        // 查成分
        if (window.location.href.match(/^https:\/\/.*\/author\/.*/)) {
            var elements = document.querySelectorAll('.um-widget');

            for (var i = 0; i < elements.length; i++) {
                var element = elements[i];

                if (element.classList.contains('follow-widget')) {
                    element.classList.remove('follow-widget');
                }
            }
        }


        什么玩意();
    };


})();