Greasy Fork is available in English.
删除黑名单用户的视频评论、收藏夹备注、显示评分投票、标题封面完整显示、等级颜色、时间跳转
当前为
// ==UserScript==
// @name 爱上ASMR - Plus
// @namespace https://www.asasmr.top/
// @version 3.6
// @description 删除黑名单用户的视频评论、收藏夹备注、显示评分投票、标题封面完整显示、等级颜色、时间跳转
// @match http*://*.asasmr3.com/*
// @match http*://*.asasmr2.com/*
// @match http*://*.asasmr1.com/*
// @match http*://*.aisasmr.com/*
// @match http*://*.aisasmr.net/*
// @license MIT
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(function() {
'use strict';
// 初始化黑名单列表
let blacklist = GM_getValue('blacklist', []);
let notes = GM_getValue('notes', {});
if (window.location.href.match(/^https:\/\/.*\/author\//) && window.location.href.match(/\?tab=collect.*/)) {
// 添加备注区域
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);
});
}
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);
}
// 创建<style>元素来保存CSS规则
const styleElement = document.createElement('style');
// 将<style>元素添加到文档的<head>部分
document.head.appendChild(styleElement);
// 定义CSS规则
const cssRules = `
/* 黑名单 */
.hmd-fbq {cursor: pointer;}
.hmd-blacklist {box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.05);overflow: auto;display: none;width: 100%;height: 100%;z-index: 110;position: fixed;background: #eeeeee;padding: 10px !important;}
.hmd-blacklist-item > a {padding: 0px 5px;}
.hmd-blacklist-item:first-child {margin-top: 50px;}
.hmd-blacklist-item {display: flex;height: 45px;align-items: center;justify-content: space-between;}
.hmd-del {background: #fff;border: solid #aaa 1px;border-radius: 4px;padding: 5px 8px;font-size: 16px;}
.hmd-add-to-blacklist {font-size: 10px !important;padding: 6px 8px !important;border-radius: 4px !important;float: right !important;margin-left: 5px !important;}
.hmdclosebutton {z-index: 120;color: #666;font-size: 30px;position: fixed;padding: 8px 20px;display: none;width: 100%;background-color: #ffffff;justify-content: flex-end;cursor: pointer;}
.hmd-blacklist-item > span {text-overflow: ellipsis;white-space: nowrap;overflow: hidden;font-size: 16px;}
.hmd-blacklist-item > button {white-space: nowrap}
/* 二次确认 */
.hmd-popup {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.5);display: none;justify-content: center;align-items: center;z-index: 9999;}
.hmd-popup-content {background-color: #fff;padding: 20px;border-radius: 5px;text-align: center;}
.hmd-popup h3 {margin-top: 0;}
.hmd-popup p {margin-bottom: 20px;}
.hmd-confirm-button,.hmd-cancel-button {padding: 8px 16px;border-radius: 4px;cursor: pointer;border: solid 1px #555;}
.hmd-confirm-button {background-color: #007bff;color: #fff;margin-right: 10px;}
.hmd-cancel-button {background-color: #ccc;}
/* 备注 */
.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: 0 4px 12px 0 rgba(0, 0, 0, 0.05);}
.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);}
/* 底栏 */
.touchy-toggle-menu {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;}
/* 等级颜色 */
.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;}
`;
// 将CSS规则添加到<style>元素中
styleElement.appendChild(document.createTextNode(cssRules));
// 在页面顶部创建黑名单显示区域
var blackListArea = document.createElement('div');
blackListArea.classList.add('hmd-blacklist');
//二次确定
const popupContainer = document.createElement("div");
popupContainer.id = "hmd-popup";
popupContainer.className = "hmd-popup";
const popupContent = document.createElement("div");
popupContent.className = "hmd-popup-content";
const heading = document.createElement("h3");
heading.textContent = "确认";
const paragraph = document.createElement("p");
paragraph.textContent = "确定要将该用户加入黑名单吗?";
const confirmButton = document.createElement("button");
confirmButton.id = "hmd-confirm-button";
confirmButton.className = "hmd-confirm-button";
confirmButton.textContent = "确认";
const cancelButton = document.createElement("button");
cancelButton.id = "hmd-cancel-button";
cancelButton.className = "hmd-cancel-button";
cancelButton.textContent = "取消";
// 将所有元素追加到它们各自的父元素中
popupContent.appendChild(heading);
popupContent.appendChild(paragraph);
popupContent.appendChild(confirmButton);
popupContent.appendChild(cancelButton);
popupContainer.appendChild(popupContent);
// 将黑名单区域添加到页面顶部
document.body.prepend(blackListArea);
document.body.prepend(popupContainer);
// 渲染黑名单列表
renderBlacklist();
// 添加“加入黑名单”按钮到评论中
// 加载更多评论监听
const threadWrapper = document.getElementById('wcThreadWrapper');
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
if (mutation.type === 'childList') {
addBlacklistButtonToComments();
shijiantiaozhuan()
blockLinks()
}
});
});
// 检查传递给 observe 方法的参数是否是有效的节点对象
if (threadWrapper instanceof Node) {
// 如果是有效的节点对象,则调用 observe 方法
observer.observe(threadWrapper, { childList: true });
} else {
}
// '加入黑名单'按钮
function addBlacklistButtonToComments() {
const comments = document.querySelectorAll('.wc-comment-right');
comments.forEach(comment => {
const commentHeader = comment.querySelector('.wc-comment-header');
const commentHeaderadd = comment.querySelector('.wc-comment-link');
const addToBlacklistButton = commentHeader.querySelector('.hmd-add-to-blacklist');
if (addToBlacklistButton) return; // 避免重复添加按钮
const username = commentHeader.querySelector('.wc-comment-author > a').innerText;
const hmdlink = commentHeader.querySelector('.wc-comment-author > a');
const hmdlinkid = hmdlink.href.match(/\/author\/\d+/);
const popup = document.getElementById('hmd-popup');
const button = document.createElement('button');
button.textContent = '黑';
button.classList.add('hmd-add-to-blacklist');
button.addEventListener('click', () => {
popup.style.display = 'flex';
const confirmButton = document.getElementById('hmd-confirm-button');
const cancelButton = document.getElementById('hmd-cancel-button');
cancelButton.addEventListener('click', () => {
popup.style.display = 'none';
confirmButton.removeEventListener('click', confirmClickHandler); // 移除确认按钮的事件监听器
});
const confirmClickHandler = () => {
blacklist.push({ username, hmdlinkid });
GM_setValue('blacklist', blacklist);
blockLinks();
renderBlacklist();
popup.style.display = 'none';
confirmButton.removeEventListener('click', confirmClickHandler); // 移除确认按钮的事件监听器
};
confirmButton.addEventListener('click', confirmClickHandler);
});
commentHeaderadd.appendChild(button);
});
}
// 渲染黑名单列表
function renderBlacklist() {
blackListArea.innerHTML = '';
blacklist.forEach(item => {
const blacklistItem = document.createElement('div');
blacklistItem.classList.add('hmd-blacklist-item');
const blacklistusername = document.createElement('span');
blacklistusername.textContent = item.username;
const blacklistlink = document.createElement('a');
blacklistlink.href = item.hmdlinkid;
blacklistlink.textContent = item.hmdlinkid;
blacklistItem.appendChild(blacklistusername);
blacklistItem.appendChild(blacklistlink);
const deleteButton = document.createElement('button');
deleteButton.textContent = '删除';
deleteButton.classList.add('hmd-del');
deleteButton.addEventListener('click', () => {
blacklist = blacklist.filter(i => i.hmdlinkid !== item.hmdlinkid);
GM_setValue('blacklist', blacklist);
renderBlacklist();
blockLinks();
});
blacklistItem.appendChild(deleteButton);
blackListArea.appendChild(blacklistItem);
});
}
// 屏蔽黑名单中的链接
function blockLinks() {
const links = document.querySelectorAll('.wc-comment-author > a');
var hostname = window.location.hostname;
// 构建完整的 URL 列表
var urls = blacklist.map(item => "https://" + hostname + item.hmdlinkid);
links.forEach(link => {
const parentElement = link.parentElement.parentElement.parentElement.parentElement;
// 检查 URL 是否在 blacklist 中
var isBlocked = urls.includes(link.href);
if (isBlocked) {
parentElement.style.display = 'none';
} else {
parentElement.style.display = '';
}
});
}
// 简介
function jianjie() {
// 换行
const dateSpan = document.querySelector('#single > div.content > div.sheader > div.data > div.extra > span.date');
const br1 = document.createElement('br');
const br2 = document.createElement('br');
dateSpan.insertAdjacentElement('afterend', br1);
dateSpan.insertAdjacentElement('afterend', br2);
// 完整图片显示
// 获取<meta property="og:image">元素的内容
const ogImageMeta = document.querySelector('meta[property="og:image"]');
const ogImageUrl = ogImageMeta ? ogImageMeta.getAttribute('content') : '';
// 替换图片链接
const dplayerVideo = document.querySelector('#single > .content > .sheader > .poster > img');
if (dplayerVideo && ogImageUrl) {
dplayerVideo.setAttribute('src', ogImageUrl);
}
// youtube超链接
// 获取.wp-content下的所有<p>元素
const paragraphs = document.querySelectorAll('.wp-content p');
// 创建一个空数组来存储结果
const youtuberesult = [];
// 遍历每个<p>元素
paragraphs.forEach((p) => {
// 检查元素是否包含"油管:"
if (p.textContent.includes('油管:')) {
// 使用正则表达式匹配包含"油管:"的那一行
const regex = /油管:(.*)/;
const match = p.textContent.match(regex);
if (match && match[1].trim() !== '') {
// 获取匹配到的文本
const matchedText = match[1];
// 分割文本为单词
const words = matchedText.split(' ');
// 遍历每个单词
words.forEach((word) => {
// 检查单词是否为空字符串
if (word.trim() !== '') {
// 创建<a>标签并设置href属性为单词链接
const link = document.createElement('a');
link.href = "https://www.youtube.com/watch?v=" + word;
link.target="_blank"
// 设置<a>标签的文本为单词
link.textContent = word;
// 将<a>标签添加到结果数组中
youtuberesult.push(link);
}
});
}
}
});
const activityBtn = document.querySelector('#info > .wp-content > .activity-btn');
youtuberesult.forEach((link) => {
activityBtn.parentNode.insertBefore(link, activityBtn);
});
}
// 视频功能
// 评论区时间跳转
function shijiantiaozhuan() {
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' // 可以选择平滑滚动效果
});
});
});
}
// 页面加载完毕时执行一次
window.onload = function() {
// 媒体页
if (window.location.href.match(/https:\/\/.*\/(video|sound)\/(\d+)\.html.*/)) {
addBlacklistButtonToComments();
shijiantiaozhuan();
jianjie();
}
// 分割线
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);
});
// 创建'黑名单'关闭按钮
var hmdcloseButton = document.createElement("i");
hmdcloseButton.innerHTML = "×"; // 使用HTML实体编码表示红色"x"
hmdcloseButton.style.display = "none";
hmdcloseButton.classList.add('hmdclosebutton');
hmdcloseButton.addEventListener("click", function() {
// 隐藏黑名单div
var blacklistDiv = document.querySelector(".hmd-blacklist");
blacklistDiv.style.display = "none";
hmdcloseButton.style.display = "none";
});
// 将关闭按钮添加到页面中
var blacklistDiv = document.querySelector(".hmd-blacklist");
blacklistDiv.parentNode.insertBefore(hmdcloseButton,blacklistDiv);
// 用户头像菜单
// 创建'黑名单'打开选项
const blacklistElement = document.querySelector('.hmd-blacklist');
const hqhmdcloseButton = document.querySelector(".hmdclosebutton");
var userlastlilist = document.querySelectorAll('.user-dashboard-dropdown ul li:last-child');
userlastlilist.forEach(function(userLastLi) {
var newuserLi = document.createElement('li');
var newuserliLink = document.createElement('a');
var newuserliLinkp = document.createElement('p');
var newuserliLinkicon = document.createElement('i');
newuserliLinkp.textContent = '黑名单';
newuserliLinkicon.classList.add('asmr');
newuserliLinkicon.classList.add('iconk-jianjie');
newuserliLink.classList.add('hmd-fbq');
newuserliLink.addEventListener('click', () => {
blacklistElement.style.display = 'block';
hqhmdcloseButton.style.display = 'flex';
});
newuserLi.appendChild(newuserliLink);
newuserliLink.appendChild(newuserliLinkicon);
newuserliLink.appendChild(newuserliLinkp);
// 将新的 li 元素插入到当前最后一个 li 元素之前
userLastLi.parentNode.insertBefore(newuserLi, userLastLi);
});
// 左侧栏
//热门
var rementargetElement = document.querySelector("#menu-item-22769 > a");
if (rementargetElement) {
rementargetElement.href = "/rmen?timeframe=week";
}
blockLinks();
};
// 监听页面刷新事件,在刷新时保留黑名单列表
window.addEventListener('beforeunload', () => {
localStorage.setItem('blacklist', JSON.stringify(blacklist));
});
})();