// ==UserScript==
// @name 内蒙古高考招生计划添加彩色标签
// @namespace http://tampermonkey.net/
// @version 2026.6.30.1
// @description 【添加彩色标签后的页面仅供参考,本人不对其负责】脚本原理只是将某些文本变为彩色背景,不会改变文本内容
// @author AN drew
// @match https://www.nm.zsks.cn/**/jhzy.html*
// @grant GM_addStyle
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
// ====================== 配置区 ======================
const CONFIG = {
// 标签颜色
colors: {
direction: '#e74c3c', // 定向 - 红色
national: '#3498db', // 国家专项计划 - 蓝色
local: '#27ae60', // 地方专项计划 - 绿色
university: '#f39c12', // 高校专项计划 - 金色
freeMedical: '#e84393', // 国家免费医学生 - 粉红
nationalTeacher: '#ad1457',// 国家公费师范生 - 紫红
localTeacher: '#722d8e', // 地方公费师范生 - 深紫色
excellentTeacher: '#2e7d32',// 优师专项 - 深绿色
military: '#215e21', // 定向培养军士生 - 军绿色
comprehensive: '#867171', // 综合评价 - 灰紫
examSchool: '#7a7bd6', // 艺考类(校考) - 浅紫蓝
examTong: '#e06d6d', // 艺考类(统考) - 浅红
planSuffix: '#8e44ad', // 专业名称中的(XXX专项计划) - 紫色
teacher: '#d35400', // 专业名称中的(师范类) - 棕色
location: '#2c3e50', // 专业名称中的(定向到XX) - 深灰蓝
officer: '#005737', // 专业名称中的(XX军官) - 松枝绿
police: '#2c3d63', // 专业名称中的(XX警官)- 警服蓝
project: '#e67e22', // 备注中的XXX项目 - 橙色
base: '#1abc59', // 备注中的XXX基地 - 浅绿色
language: '#167b67', // 外语语种 - 墨绿
subject: '#00b894', // 选科要求 - 薄荷绿
army: '#7eb526', // 陆军
navy: '#000062', // 海军
airForce: '#508ce4', // 空军
rocket: '#ea7901', // 火箭军
spaceForce: '#1d3b79', // 军事航天部队
cyberForce: '#65666a', // 网络空间部队
infoSupport: '#640772', // 信息支援部队
jointLogistics: '#296d3e', // 联勤保障部队
armedPolice: '#134a2d', // 武警部队
fireRescue: '#DE5306', // 消防救援队伍
},
// 匹配关键词
keywords: {
direction: '定向',
national: '国家专项计划',
local: '地方专项计划',
university: '高校专项计划',
freeMedical: '国家免费医学生',
nationalTeacher: '国家公费师范生',
localTeacher: '地方公费师范生',
excellentTeacher: '优师专项',
military: '定向培养军士生',
comprehensive: '综合评价',
examSchool: '艺考类(校考)',
examTong: '艺考类(统考)',
planSuffix: /([^)]*专项计划)/g, // 匹配(XXX专项计划)
teacher: /(师范(?:类)?)/g, // 匹配(师范类)
location: /(定向到[^)]*)|定向到[^,,。]*|((?![^)]*(?:自治区|直辖|城市))[^)]*[市县旗])/g, // 匹配(定向到XX)
officer: /((?:[^()]|([^()]*))*军官(?:[^()]|([^()]*))*)/g, // 匹配(XX军官)
police: /([^)]*?(?:警官|入警就业|地方公安方向|移民方向|铁路公安方向|法院警务方向|检察院警务方向|狱内侦查方向|戒毒方向))/g, // 匹配(XX警官)
project: /[^,,。、;:]{2,}(? {
return `.tag-${key} { background-color: ${CONFIG.colors[key]}; }`;
}).join('\n');
GM_addStyle(`
/* 通用标签样式 */
.tag-label {
display: inline-block;
padding: 1px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: 600;
line-height: 1.6;
letter-spacing: 0.3px;
white-space: nowrap;
color: #fff;
margin: 0 2px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
${styleRules}
`);
GM_addStyle(`
/* 让单元格内容更整齐 */
#table tbody td {
vertical-align: middle;
}
/* 备注列允许换行,但标签不换行 */
#table tbody td:nth-child(11) .tag-label {
white-space: nowrap;
}
/* 专业名称列(第3列)整体加粗 */
#table tbody td:nth-child(3) {
font-weight: bold;
text-align: left !important;
}
/* 该列中的标签独占一行,并保持间距 */
#table tbody td:nth-child(3) .tag-label {
display: block;
width: fit-content;
max-width: 100%;
margin: 2px 0;
}
/* 专业名称列中,特定标签保持行内 */
#table tbody td:nth-child(3) .tag-label.inline-tag {
display: inline-block !important;
width: auto !important;
max-width: none !important;
margin: 0 2px !important;
}
/* 计划类别列中,需要独占一行并居中的标签 */
#table tbody td:nth-child(5) .block-center {
display: block;
text-align: center;
margin: 2px auto;
width: fit-content;
}
`);
// ====================== 工具函数 ======================
const FEMALE_SVG = ``;
const MALE_SVG = ``;
/** 在男生/女生后面添加对应svg图标 */
function appendGenderIcon(text) {
if (typeof text !== 'string') return text;
// 如果已包含SVG,直接返回原文本
if (text.includes('