您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add purple bold font style for all names of beatmap nominators in osu! website
当前为
// ==UserScript== // @name osu! Highlight For BN Names // @namespace https://osu.ppy.sh/u/376831 // @include *osu.ppy.sh/g/28* // @include *osu.ppy.sh/forum/ucp.php* // @include *osu.ppy.sh/forum/60* // @include *osu.ppy.sh/u/* // @include *osu.ppy.sh/forum/t* // @version 1.2.1 // @description Add purple bold font style for all names of beatmap nominators in osu! website // @grant none // ==/UserScript== var bnColor = '#8040FF'; var cookiesSaveDays = 7; window.onload = function () { var title = document.title; var url = document.URL; switch (title) { case 'osu! - Beatmap Nomination Group': var bnNumber = getBnNumber(); removeBnList(bnNumber); addBnList(); break; case 'Front page': var friends = getChilds(getElements('profile_friend ')); var multiFriends = getChilds(getElements('profile_friend mutual')); var bnList = getBnList(); addStyleToBn(friends, bnList, true, false); addStyleToBn(multiFriends, bnList, true, false); break; case 'Modding Queues': var posters = getChilds(getElements('topicauthor')); var bnList = getBnList(); addStyleToBn(posters, bnList, true, false); break; } if (url.indexOf('osu.ppy.sh/u/') != - 1) { var userName = document.getElementsByClassName('profile-username'); var bnList = getBnList(); addStyleToBn(userName, bnList, false, false); } if (url.indexOf('osu.ppy.sh/forum/t') != - 1) { var posters = document.getElementsByClassName('postauthor'); var bnList = getBnList(); addStyleToBn(posters, bnList, false, true); } }; function getElements(name) { return document.getElementsByClassName(name); } function getChilds(elements) { var childs = new Array(); for (var i = 0; i < elements.length; i++) { childs[i] = elements[i].firstChild; } return childs; } function isElementBn(element, bnList) { for (var i = 0; i < bnList.length; i++) { if (element.innerHTML.trim() == bnList[i]) { return true; } } return false; } function addStyleToElement(element, isBold, isInThread) { element.style['color'] = bnColor; if (isBold) { element.style['font-weight'] = 'bold'; } if (isInThread) { element.parentNode.parentNode.parentNode.parentNode.parentNode.style['border-top'] = 'solid 3px #FFCA22'; } } function addStyleToBn(elements, bnList, isBold, isInThread) { for (var i = 0; i < elements.length; i++) { if (isElementBn(elements[i], bnList)) { addStyleToElement(elements[i], isBold, isInThread); } } } function getBnNumber() { var bnNumber = parseInt(getCookie('bnUserNumber')); if (isNaN(bnNumber)) { bnNumber = 150; } return bnNumber; } function removeBnList(bnNumber) { for (var i = 0; i < bnNumber; i++) { removeCookie('bnUserNames' + i); } removeCookie('bnUserNumber'); } function addBnList() { var userNames = getElements('username'); addCookie('bnUserNumber', userNames.length); for (var i = 0; i < userNames.length; i++) { addCookie('bnUserNames' + i, userNames[i].innerHTML); } } function getBnList() { var bnNumber = getBnNumber(); var bnList = new Array(); for (var i = 0; i < bnNumber; i++) { bnList[i] = getCookie('bnUserNames' + i); } return bnList; } function addCookie(name, value) { var exp = new Date(); exp.setTime(exp.getTime() + cookiesSaveDays * 24 * 60 * 60 * 1000); document.cookie = name + '=' + value + ';expires=' + exp.toGMTString() + ';path=/'; } function removeCookie(name) { document.cookie = name + '=;expires=' + (new Date(0)).toGMTString() + ';path=/'; } function getCookie(name) { var arr, reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); if (arr = document.cookie.match(reg)) { return unescape(arr[2]); } else { return null; } } function trim(str) { str = str.replace(/^(\s|\u00A0)+/, ''); for (var i = str.length - 1; i >= 0; i--) { if (/\S/.test(str.charAt(i))) { str = str.substring(0, i + 1); break; } } return str; }