// ==UserScript== // @name 爱上ASMR - Plus // @namespace https://www.asasmr.top/ // @version 6.1 // @description 视频评论黑名单屏蔽词、收藏夹备注、音视频下载、评论区时间跳转、显示评分投票、标题封面完整显示、禁用动态头像、 // @author 真是一坨大的根本看不懂<( _ _ )> // @include /https?\:\/\/.*\.asasmr\d\.com\/.*/ // @match http*://*.asasmr0.com/* // @match http*://*.aisasmr.com/* // @icon https://asmrscj.com/assets/images/logos/as111.png // @run-at document-body // @grant GM_getValue // @grant GM_setValue // @grant GM_addStyle // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // jquery const jqUrl = "https://code.jquery.com/jquery-3.7.1.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', {}); let hmdList = GM_getValue('hmdList', []); let regexList = GM_getValue('regexList', [ '(? p {height: 48px;} /* 黑名单 */ .hmd-add-to-blacklist {font-size: 11px !important;padding: 5px !important;border-radius: 4px !important;float: right !important; margin-left: 5px !important; color: #eeeeeeee !important; } /* 屏蔽词 */ #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;} /* 自定sidemenu列表 */ #hmd-list > li, #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); } #hmd-list > li > span, #regex-list > li > span {padding: 0 6px;color: #000;text-overflow: ellipsis;white-space: nowrap; overflow: hidden; width: 150px; } #hmd-list > li > span {color: #0693e3;text-decoration: underline;cursor: pointer;} /* 顶栏 */ .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: "\ue633" !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;} /* 音视频下载 */ .button-container { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 20px; margin: auto; width: fit-content; } .button-container > button{ padding: 4px 6px; border-radius: 4px; /* padding:10px 20px; border:2px solid transparent; border-radius:20px; background:#f8f9fa; color:#343a40; font-size:16px; font-family:'Arial',sans-serif;cursor:pointer; transition:background-color .3s,transform .3s; box-shadow:0 2px 4px rgba(0,0,0,.1) */ } .button:hover{background:#e9ecef;transform:translateY(-2px);box-shadow:0 4px 8px rgba(0,0,0,.2)} .button:active{background:#dee2e6;transform:translateY(0);box-shadow:0 2px 4px rgba(0,0,0,.1)} #copy-video-link{border-color:#dc3545;color:#dc3545} #copy-video-linkb{border-color:#6c757d;color:#6c757d} #copy-audio-link{border-color:#17a2b8;color:#17a2b8} #download-video-with-1dm{border-color:#ffc107;color:#ffc107} #download-video-with-1dmb{border-color:#e83e8c;color:#e83e8c} #download-audio-with-1dm{border-color:#28a745;color:#28a745} #copy-video-link:hover{color:#dc3545} #copy-video-linkb:hover{color:#6c757d} #copy-audio-link:hover{color:#17a2b8} #download-video-with-1dmb:hover{color:#e83e8c} #download-video-with-1dm:hover{color:#ffc107} #download-audio-with-1dm:hover{color:#28a745} .button:hover, #copy-video-link:hover, #copy-video-linkb:hover, #copy-audio-link:hover, #download-video-with-1dm:hover, #download-video-with-1dmb:hover, #download-audio-with-1dm:hover { background:#fff } /* 音视频页面 */ /* 简介区 */ /* 评论区 */ #wpcomm .wc-comment-footer .wc-footer-left {float: left !important;} #wpcomm .wc-comment-footer .wc-footer-right {float: right !important;} .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;} #aplload:hover {background: #888888;} .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;} /* 等级颜色 */ .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;} /* 深色模式 */ .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";} .poster a.thumb-link:hover {background-color: #00000022;} 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;} `) // 简介 function 简介() { // 简介封面 const $dateSpan = $('#single > .content > .sheader > .data > .extra > .date'); $dateSpan.after('

'); // 完整封面 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 => `油管: ${videoId}`); 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 `${match}`; }); }); // 将视图定位到 播放器 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 createRegexListItem(item, index) { const listItem = document.createElement('li'); const span = document.createElement('span'); const button = document.createElement('button'); let removeFunction; if (typeof item === 'object' && item !== null) { span.textContent = item.name; span.addEventListener('click', function () { var url = `/author/${item.id}`; window.open(url, '_blank'); }); removeFunction = removehmd; } else { span.textContent = item; span.title = item; removeFunction = removeRegex; } button.className = 'pbcan'; button.textContent = '删除'; button.addEventListener('click', function () { listItem.style.display = 'none'; removeFunction(index); }); listItem.appendChild(span); listItem.appendChild(button); return listItem; } function getDirectTextContent(element) { return Array.from(element.childNodes) .filter(node => node.nodeType === Node.TEXT_NODE) .map(node => node.nodeValue.trim()) .join(''); } // 评论区 // 黑名单 function 加入黑名单按钮() { const commentHeaders = document.querySelectorAll('.wc-comment-header'); commentHeaders.forEach((header) => { const addToBlacklistButton = header.querySelector('.hmd-add-to-blacklist'); if (addToBlacklistButton) return; const commentLink = header.querySelector('.wc-comment-link'); const authorLink = header.querySelector('.wc-comment-author > a'); const button = document.createElement('button'); button.textContent = '黑'; button.classList.add('hmd-add-to-blacklist'); commentLink.appendChild(button); button.addEventListener('click', () => { const authorName = getDirectTextContent(authorLink); const authorIdMatch = authorLink.href.match(/\/author\/(\d+)/); const authorId = authorIdMatch ? authorIdMatch[1] : null; if (authorId) { Swal.fire({ title: '确定要添加吗?', html: `Name:${authorName}
ID:${authorId}`, icon: 'question', showCancelButton: true, confirmButtonText: '确定', cancelButtonText: '取消' }).then((result) => { if (result.isConfirmed) { header.parentElement.parentElement.style.display = 'none'; const hmdStr = {name: authorName, id: authorId} hmdList.push(hmdStr); const regexListElement = document.getElementById('hmd-list'); const lastIndex = regexList.length - 1; const listItem = createRegexListItem(hmdStr, lastIndex); regexListElement.appendChild(listItem); GM_setValue('hmdList', hmdList); /* Swal.fire({ title: '成功添加 ' + authorName + ' 加入黑名单', text: '1秒后自动关闭', timer: 1500, timerProgressBar: true, }) */ } }); } }); }); } // 删除指定的黑名单用户 function removehmd(index) { hmdList.splice(index, 1); sethmdList([...hmdList]); } function 屏蔽黑名单用户的评论() { const comments = document.querySelectorAll('.wc-comment .wc-comment-author > a'); comments.forEach(authorLink => { const authorid = authorLink.href.match(/\/author\/(\d+)/)[1]; const hmdListItem = hmdList.find(item => item.id === authorid); if (hmdListItem) { authorLink.closest('.wc-comment').style.display = 'none'; } }); } // 屏蔽词 // 添加新的屏蔽词到列表 function addRegex(regexStr) { try { new RegExp(regexStr); if (!regexList.includes(regexStr)) { regexList.push(regexStr); setRegexList([...regexList]); const regexListElement = document.getElementById('regex-list'); const lastIndex = regexList.length - 1; const listItem = createRegexListItem(regexStr, lastIndex); regexListElement.appendChild(listItem); } } catch (error) { console.error("Invalid regular expression: ", regexStr); Swal.fire({ title: "请输入有效的正则表达式", timer: 10000, timerProgressBar: true, }) } } // 删除指定的屏蔽词 function removeRegex(index) { regexList.splice(index, 1); setRegexList([...regexList]); } // 检查文本是否应该被屏蔽 function isBlocked(text) { 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'; } }); } // 加载更多评论后执行相关函数 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 签到(element) { // 签到页面 const apiUrl = window.location.origin + '/mission' document.querySelectorAll('.asmr.iconk-qiandao').forEach(function(element) { element.parentElement.addEventListener('click', function(event) { event.preventDefault(); }); }); document.querySelector(element).addEventListener('click', () => { const currentDate = new Date().toISOString().slice(0, 10); let lastSignInDate = localStorage.getItem('lastSignInDate') || '1970-01-01'; if (currentDate === lastSignInDate) { Swal.fire({ title: '今日已签到', text: '是否前往签到页面?', showCancelButton: true, confirmButtonText: '是', cancelButtonText: '否' }).then((result) => { if (result.isConfirmed) { window.open(apiUrl, '_blank'); } }); } else { Swal.fire({ title: '是否签到?', showCancelButton: true, confirmButtonText: '是', cancelButtonText: '否' }).then((result) => { if (result.isConfirmed) { 请求签到(apiUrl); localStorage.setItem('lastSignInDate', currentDate); } }); } }); } async function 请求签到(apiUrl) { try { const response = await fetch(apiUrl); if (!response.ok) throw new Error('未能从服务器获取数据'); const html = await response.text(); const parser = new DOMParser(); const doc = parser.parseFromString(html, 'text/html'); const elements = doc.querySelector('#dt_reset_api-js-extra'); if (!elements) throw new Error('未能找到目标元素'); const wpnonceMatch = elements.textContent.match(/"wp_rest":"([a-zA-Z0-9]+)"/); const wpnonce = wpnonceMatch ? wpnonceMatch[1] : null; if (!wpnonce) throw new Error('未能获取_wpnonce'); const missionResponse = await fetch(`/wp-json/as/v1/userMission?_wpnonce=${wpnonce}`, { headers: { accept: "application/json, text/javascript, */*; q=0.01", }, referrer: apiUrl, method: "POST", }); if (!missionResponse.ok) throw new Error('签到请求失败'); const data = await missionResponse.json(); console.log(data); Swal.fire({ title: '签到成功', icon: 'success' }); } catch (error) { console.error(error); Swal.fire({ title: '签到失败', text: error.message, icon: 'error' }); } } // 设置移动设备侧栏开关状态 function toggleActiveClass() { // 移动设备侧栏开关 var mobileNav = document.querySelector('.mobile-nav'); var mobileoverlay = document.querySelector('.mobile-overlay'); mobileNav.classList.toggle('active'); mobileoverlay.classList.toggle('active'); } function mobileMain() { GM_addStyle(` #regex-list > li > span {white-space: normal !important;} `) // 用户菜单 $('.responsive .iconk-bianji').eq(1).removeClass('iconk-bianji').addClass('iconk-dingyue'); // 顶栏 var $qiandaolement = $('.responsive > .search > .search-resp'); const head = document.querySelector('.top-my-home').href; $qiandaolement.attr('href', head + '?tab=SC'); var $divElement = $('
').attr('id', 'advc-menu').addClass('searchs') .css({ 'float': 'left', 'padding': '10px 0px 8px 5px' }); // 搜索框 var $formElement = $('
', {id: 'searchform',action: window.location.origin,method: 'get'}).css('display', 'flex'); var $inputElement = $('', {type: 'text',class: 'form-control',placeholder: '搜索...',name: 's',id: 's'}).val(''); // 搜索按钮 var $buttonElement = $('