-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-boldless-title.user.js
47 lines (41 loc) · 1.77 KB
/
github-boldless-title.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ==UserScript==
// @name GitHub Boldless Title
// @namespace https://github.com/Vinfall/UserScripts
// @version 1.0.2
// @author Vinfall
// @match https://github.com/*
// @exclude-match https://github.com/login
// @exclude-match https://github.com/sessions/*
// @exclude-match https://github.com/signin
// @grant none
// @run-at document-end
// @license CC0 1.0 Universal (Public Domain)
// @icon
// @description Remove strong style in GitHub repo title
// @description:zh-cn GitHub 仓库名取消加粗
// ==/UserScript==
// Mostly used to avoid unwanted bold marker in Obsidian...
(function () {
'use strict';
function replaceStrongWithAnchor() {
const strongElements = document.querySelectorAll('strong.mr-2.flex-self-stretch');
strongElements.forEach((strong) => {
const anchor = strong.querySelector('a'); // Select the <a> tag inside <strong>
if (anchor) {
// Create a new <a> element
const newAnchor = document.createElement('a');
newAnchor.href = anchor.href; // Preserve the href
newAnchor.textContent = anchor.textContent; // Preserve the text content
// Replace the <strong> element with the new <a> element in the DOM
strong.parentNode.replaceChild(newAnchor, strong);
}
});
}
// Run after the window has fully loaded
window.onload = () => {
replaceStrongWithAnchor();
// Observe changes in the page (e.g., for dynamic content)
const observer = new MutationObserver(replaceStrongWithAnchor);
observer.observe(document.body, { childList: true, subtree: true });
};
})();