// ==UserScript==
// @name Display Oxford Admission Metadata
// @name:zh-CN 显示牛津录取玄学
// @namespace https://blog.frankie.science
// @version 1.8
// @description Parse and display metadata comments with toggleable OFFERDOCS
// @description:zh-CN 解析并显示元数据注释,带可切换的 OFFERDOCS
// @author Frankie
// @match *://*/*
// @grant none
// @license MIT License with Attribution
// @downloadURL https://update.greasyfork.icu/scripts/534644/Display%20Oxford%20Admission%20Metadata.user.js
// @updateURL https://update.greasyfork.icu/scripts/534644/Display%20Oxford%20Admission%20Metadata.meta.js
// ==/UserScript==
// Additional clause:
// 1. Any redistribution or modification must retain the original donation link and cannot remove or modify it.
(function () {
'use strict';
// 正则表达式匹配单个注释块
const metadataRegex = //g;
// 子表达式解析注释内容
const contentRegex = /docs:\s*(\d+),\s*#OFFERDOCS:\s*\|([^|]+(?:\|[^|]+)*)\|([^,]+),\s*#DALS:\s*([A-Z]+)/;
// 获取页面 HTML 并匹配所有注释
const pageContent = document.documentElement.innerHTML;
const matches = [...pageContent.matchAll(metadataRegex)];
const metadataList = [];
// 遍历每个注释块
matches.forEach(match => {
const commentContent = match[1].trim();
const contentMatch = commentContent.match(contentRegex);
if (contentMatch) {
metadataList.push({
docs: contentMatch[1],
offerDocsRaw: contentMatch[2],
offerDocsDesc: contentMatch[3],
dals: contentMatch[4]
});
}
});
if (metadataList.length > 0) {
// 创建一个浮动窗口来显示数据
const metadataBox = document.createElement('div');
metadataBox.style.position = 'fixed';
metadataBox.style.top = '10px';
metadataBox.style.right = '10px';
metadataBox.style.backgroundColor = '#f9f9f9';
metadataBox.style.border = '1px solid #ccc';
metadataBox.style.padding = '10px';
metadataBox.style.zIndex = '10000';
metadataBox.style.fontSize = '14px';
metadataBox.style.fontFamily = 'Arial, sans-serif';
metadataBox.style.color = '#333';
metadataBox.style.maxHeight = '90%';
metadataBox.style.overflowY = 'auto';
metadataBox.innerHTML = `Metadata Information
`;
// 遍历每条注释内容并显示
metadataList.forEach((metadata, index) => {
const offerDocsList = metadata.offerDocsRaw.split('|');
const offerDocsContent = `