// ==UserScript==
// @name 暴力猴控制台美化
// @namespace Violentmonkey Scripts
// @match https://greasyfork.org/zh-CN/users/*
// @grant none
// @version 0.1.2
// @author aliha
// @description 美化暴力猴控制台|
// @icon
// @run-at
// @license MIT
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
function mooc() {
const parents = document.getElementById('user-script-list-section')
// 获取要复制的
元素
const liElement = parents.querySelector('li');
// 克隆 元素的内容
const clonedLiElement = liElement.cloneNode(true);
// 将克隆后的元素添加到相同的父元素中,即 ol 元素
const olElement = document.querySelector('#user-script-list');
olElement.appendChild(clonedLiElement);
}
mooc()
mooc()
mooc()
mooc()
mooc()
const menuItems = [
{ className: 'script-list-sort', title: '脚本排序' },
{ className: 'script-list-filter', title: '生效过滤' },
{ className: 'script-language-filter', title: '编程语言' }
];
const userMenuTextMapping = {
"发布你编写的脚本": "发布脚本",
"发布你编写的样式": "发布样式",
"新建脚本收藏集": "新建收藏",
"设置 webhook": "Webhook",
"编辑账号信息": "账号信息",
"更改登录方式": "登录方式",
"编辑通知": "通知方式",
"退出": "退出登录"
};
// 设置脚本菜单小标题
function setScriptListTitle() {
const headerElement = document.querySelector("#user-script-list-section header");
const h3Element = headerElement.querySelector("h3");
const divElement = document.createElement("div");
divElement.textContent = h3Element.textContent;
headerElement.replaceChild(divElement, h3Element);
}
// 更改右侧菜单的标题
function ModifyScriptListTitle(className, titleName) {
const parentElement = document.getElementById(className);
const originalTextElement = parentElement.firstChild;
parentElement.removeChild(originalTextElement);
const titleDiv = document.createElement('div');
titleDiv.className = 'list-option-title';
titleDiv.textContent = titleName;
parentElement.insertBefore(titleDiv, parentElement.firstChild);
}
// 移动菜单
function moveMenu() {
const leftMenuDiv = document.createElement("div");
leftMenuDiv.className = "left-menu";
const sectionsToMove = [
"about-user",
"user-discussions-on-scripts-written",
"user-discussions",
"user-conversations",
"user-script-sets-section"
];
const sidebarred = document.querySelector(".sidebarred");
sidebarred.insertBefore(leftMenuDiv, sidebarred.firstChild);
sectionsToMove.forEach(sectionId => {
const section = document.getElementById(sectionId);
leftMenuDiv.appendChild(section);
});
const textContentElements = document.querySelectorAll('.text-content');
textContentElements.forEach(element => {
element.style.margin = '0';
element.style.border = 'none';
element.style.borderRadius = '0';
element.style.boxShadow = 'none';
});
const discussionsTitle = document.querySelector("#user-discussions-on-scripts-written h3");
const scriptSetsTitle = document.querySelector("#user-script-sets-section h3");
if (discussionsTitle) {
discussionsTitle.textContent = "相关讨论";
}
if (scriptSetsTitle) {
scriptSetsTitle.textContent = "脚本收藏";
}
const h3Elements = document.querySelectorAll("h3");
h3Elements.forEach(h3Element => {
const newDivElement = document.createElement("div");
newDivElement.textContent = h3Element.textContent;
newDivElement.className = "list-option-title";
h3Element.parentNode.replaceChild(newDivElement, h3Element);
});
}
// 修改用户菜单
function modifyUserMenu() {
const controlPanelLinks = document.querySelectorAll("#user-control-panel li a");
controlPanelLinks.forEach(link => {
const originalText = link.textContent.trim();
const newText = userMenuTextMapping[originalText];
if (newText) {
link.textContent = newText;
}
});
const aboutUserSection = document.getElementById("about-user");
const userDiscussions = document.getElementById("user-discussions");
const userConversations = document.getElementById("user-conversations");
const discussionsLink = userDiscussions.querySelector("ul a");
const userConversationsLink = userConversations.querySelector("P");
const reportLink = aboutUserSection.querySelector(".report-link");
const h2Element = aboutUserSection.querySelector("h2");
const right = document.querySelector('.sidebar.collapsed');
const elementToRemove = right.querySelector('.close-sidebar');
// 检查元素是否存在,然后将其删除
if (elementToRemove) {
elementToRemove.remove(); // 删除元素
}
if (discussionsLink) {
discussionsLink.remove();
}
if (userConversationsLink) {
userConversationsLink.remove();
}
if (reportLink) {
reportLink.remove();
}
if (h2Element) {
h2Element.remove();
}
}
// 添加 CSS 样式
function addCustomStyles() {
const style_css = document.createElement('style');
style_css.textContent = `
/* CSS 样式内容 */
/* 隐藏浏览器默认的滚动条 */
::-webkit-scrollbar {
width: 0px; /* 设置滚动条宽度 */
}
/* 滚动条轨道 */
::-webkit-scrollbar-track {
background-color: #f1f1f1; /* 设置滚动条轨道背景颜色 */
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
background-color: #888; /* 设置滚动条滑块颜色 */
border-radius: 6px; /* 设置滑块边角的圆角 */
}
/* 当鼠标悬停在滑块上时 */
::-webkit-scrollbar-thumb:hover {
background-color: #555; /* 设置滚动条滑块的悬停颜色 */
}
html, body{
margin: 0;
padding: 0;
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
ul, ol{
list-style-type: none;
margin:0;
}
p {
margin-top:0;
margin-left:20px;
}
.width-constraint {
margin: 0;
height: 100%;
max-width: 100%;
}
#main-header {
background-color: #545c64;
box-shadow: none;
}
#main-header a {
text-decoration: none;
}
#site-name img {
display: none;
}
.sidebarred {
flex: 1;
height: 100%;
max-height:88vh;
}
.sidebar.collapsed, .sidebarred-main-content {
margin: 0;
padding: 0;
}
.sidebar {
width: 200px;
background-color: #6e767d;
}
.sidebarred-main-content {
border: none;
max-width: 100%;
background-color: #e9e9eb;
margin-left: auto;
}
#about-user, .text-content {
margin: 0;
border: none;
border-radius: 0;
box-shadow: none;
padding:0;
}
#user-control-panel {
background-color: #dcdfe6;
}
a {
text-decoration: none;
}
.left-menu {
width:221px;
background-color:#6e767d;
}
/* 搜索选项 */
.close-sidebar, .list-option-title {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
cursor: pointer;
background-color: #545c64; /* 调整背景颜色 */
color: #fff; /* 调整文本颜色 */
height:21px;
}
/* 设置字体颜色为 #e7bf4b 并加粗 */
.close-sidebar div {
color: #e7bf4b; /* 设置字体颜色 */
font-weight: bold; /* 加粗字体 */
font-family: "黑体", sans-serif; /* 使用黑体字体 */
}
.close-sidebar .sidebar-title,
.close-sidebar div:nth-child(2) {
visibility: hidden;
}
/* 搜索选项 - 选项菜单 */
.list-option-groups {
justify-content: space-between;
align-items: center;
padding: 0px;
cursor: pointer;
background-color: #e9eef3;
}
.list-option-group {
padding: 0;
margin: 0;
}
.list-option-title {
background-color: #6e767d;
}
.list-option-group ul {
box-shadow: none;
border: none;
border-radius: 0;
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
background-color: #DCDFE6;
}
.list-option-group a {
text-decoration: none;
}
.list-option-group .list-current {
border-left: none;
box-shadow: none;
margin: 0;
padding: .4em 1em .4em calc(1em - 3px);
background: #F2F6FC;
}
/* 脚本列表 - 脚本list */
#user-script-list {
border: none;
padding-top: 0;
margin-top: 0;
background: none;
box-shadow: none;
overflow-y: auto;
max-height: 82vh;
}
#user-script-list-section {
margin: 0;
padding: 0;
}
#user-script-list-section li {
border-bottom: 1px solid #ccc;
border-radius: 2px;
margin-bottom: 2px;
list-style: none;
background-color: #ffffff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
border-radius: 4px;
margin: 5px;
padding: 15px;
display: flex;
flex-direction: column;
transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
#user-script-list-section li:hover {
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2); /* 增加阴影大小 */
background-color: #f0f0f0; /* 更改背景颜色 */
}
/* 脚本列表 - 脚本title */
#user-script-list-section header {
background-color: #545c64; /* 调整背景颜色 */
color: #fff; /* 调整文本颜色 */
padding: 0;
height: 41px;
display: flex;
justify-content: center;
}
#user-script-list-section header div {
display: flex;
align-items: center;
justify-content: space-around;
text-align: center;
width: calc(100% - 20px);
height: 100%;
color: #e7bf4b;
font-weight: bold;
font-family: "黑体", sans-serif;
}
/* ... */
`;
document.head.appendChild(style_css);
}
menuItems.forEach(menuItem => {
ModifyScriptListTitle(menuItem.className, menuItem.title);
});
setScriptListTitle();
moveMenu();
modifyUserMenu();
addCustomStyles();
})();