您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Destacar comentarios de usuarios con menos de NOOB_DAYS días.
当前为
// ==UserScript== // @name meneame.net - Destacar comentarios de usuarios recientes // @namespace http://tampermonkey.net/ // @version 2.8 // @description Destacar comentarios de usuarios con menos de NOOB_DAYS días. // @author Niko & оᴄнᴏсᴇʀоs // @match *://*.meneame.net/* // @connect meneame.net // @icon https://www.meneame.net/favicon.ico // @grant GM_addStyle // @grant GM.setValue // @grant GM.getValue // @grant GM.listValues // @grant GM.deleteValue // @grant GM.xmlHttpRequest // @license GNU GPLv3 // ==/UserScript== // ---- SCRIPT CONFIG ---- const CACHE_DAYS = 30; const GREEN_DAYS = 30; const ORANGE_DAYS = 30; const RED_DAYS = 30; const GREEN_COLOR = "#0ba800"; //FILLCOLOR const ORANGE_COLOR = "#ffa200"; const RED_COLOR = "#ff0000"; const NOOB_DAYS = RED_DAYS + ORANGE_DAYS + GREEN_DAYS; const FILLCOLOR = 'FILLCOLOR'; // ---- API values ---- const USER_LOCATIONS = [ ['.username',null], ['.news-submitted',3] ]; const REQUEST_URL = 'https://www.meneame.net/backend/get_user_info?id='; const AVATAR_CLASSES = '.avatar, .lazy'; const SVG_CSS_Tooltip = "a.SVGtooltips {position: relative;display: inline;top: 5px; left: -17px;} a.SVGtooltips span {position: absolute;width:50px;color: #FFFFFF;background: #000000;height: 30px;line-height: 30px;text-align: center;visibility: hidden;border-radius: 6px;} a.SVGtooltips span:after {content: '';position: absolute;top: 50%;right: 100%;margin-top: -8px;width: 0; height: 0;border-right: 8px solid #000000;border-top: 8px solid transparent;border-bottom: 8px solid transparent;} a:hover.SVGtooltips span {visibility: visible;opacity: 1;left: 100%;top: 50%;margin-top: -15px;margin-left: 15px;z-index: 999;}"; const SVG_L_PIC = "<a class='SVGtooltips' href='#'> <svg width='11' height='12' style='overflow: visible'> <rect style='fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.23;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' height='16.55' ry='0.88' rx='0.88' width='14.89' x='-0.09' y='-0.09'></rect> <rect rx='0.55' ry='0.55' height='14.89' x='0.73' y='0.73' width='13.24' style='fill:FILLCOLOR;fill-opacity:1;stroke:#000000;stroke-width:0.20;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1'></rect> <path style='fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.09;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1' d='M 2.77,1.66 V 14.71 h 3.30 v -0.0058 H 11.92 V 12.18 L 5.50,12.16 V 1.64 Z'></path></svg><span>XXX DÍAS</span></a>"; function DoDirtyThings() { cacheDelete(); GM_addStyle(SVG_CSS_Tooltip); highlightNoobUsers(); }; function highlightNoobUsers() { for(var userLocation of USER_LOCATIONS) { let usernames = document.querySelectorAll(userLocation[0]); let childNodeNumber = userLocation[1]; usernames.forEach(function(node) { checkIfUserIsNoob(node, childNodeNumber); }); } } async function checkIfUserIsNoob(node, childnode) { var user = ""; if (childnode) { user = node.childNodes[childnode].textContent; } else { user = node.textContent; } let date = await GM.getValue(user, ""); if (date === "") date = requestRegistrationDate(user); let days = daysSinceRegistration(date); if (days < NOOB_DAYS) InsertAfterAvatar(node, FormatSVG(Math.floor(days))); } function FormatSVG(days) { var strSVG = SVG_L_PIC.replace("XXX",days); switch(true) { case (days <= RED_DAYS): strSVG = strSVG.replace(FILLCOLOR, RED_COLOR); break; case (days <= RED_DAYS + ORANGE_DAYS): strSVG = strSVG.replace(FILLCOLOR, ORANGE_COLOR); break; default: strSVG = strSVG.replace(FILLCOLOR, GREEN_COLOR); } if (days == 1) strSVG = strSVG.replace('DÍAS', 'DÍA'); return strSVG; } function InsertAfterAvatar(usernode, htmlsvg) { let avatarNodes = usernode.parentNode.querySelectorAll(AVATAR_CLASSES); avatarNodes.forEach(function(node) { node.insertAdjacentHTML('afterend', htmlsvg); }); } async function requestRegistrationDate(user) { await GM.xmlHttpRequest( {method: "GET", url: REQUEST_URL + user, onload: function(result) { const dateRegex = /((0[1-9]|[12]\d|3[01])-(0[1-9]|1[0-2])-[12]\d{3})/; const date = result.responseText.match(dateRegex); if (user != "") GM.setValue(user, date[0]); } } ); } function daysSinceRegistration(dateStr) { const dateArray = dateStr.toString().split('-'); const date = new Date(dateArray[2], dateArray[1] - 1, dateArray[0]); return (Date.now() - date.getTime()) / 8.64e7; } async function cacheDelete() { const UPDATE_DATE_KEY = "_CACHE_CLEAR_DATE_" let lastClearDate = await GM.getValue(UPDATE_DATE_KEY, ""); if (lastClearDate === "") { GM.setValue(UPDATE_DATE_KEY, Date.now()); } else { if ((Date.now() - lastClearDate) / 8.64e7 > CACHE_DAYS) { let values = await GM.listValues(); values.forEach( function(value) {GM.deleteValue(value);}); GM.setValue(UPDATE_DATE_KEY, Date.now()); } } } DoDirtyThings();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址