Content deleted Content added
template literals for better readability |
avoid bug for italics |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1:
/*** Unfolded and numbered TOC for Vector 2022 ***/
// Unfolds the
// This script is a modified version of the code found at https://greasyfork.org/en/scripts/458558-wikipedia-vector-2022-better-toc .
// It is licensed under the MIT
(function () {
// check whether the
if (document.body.classList.contains("skin-vector-2022")){
// compose stylesheet contents
Line 12:
// show numbers
stylesheetContents += `
.vector-toc-numb { display: inline !important
}`;
// add space after numbers
stylesheetContents += `
.vector-toc-numb:after { content: " "
}`;
// hide unfold button
stylesheetContents += `
.vector-toc-level-1 > button { display: none !important;
}`;
// adjust spacing
stylesheetContents += `
.vector-toc-text { padding: 2px 0 !important;
gap: 0.25em;▼
display: flex;
▲ gap: 0.25em
}
Line 40 ⟶ 43:
.vector-toc .vector-toc-numb, .vector-toc .vector-toc-numb:after {
display: inline !important; white-space: pre;
}
`;
// add stylesheet to document
Line 47 ⟶ 51:
document.head.append(stylesheet);
// unfold
const listElements = document.getElementsByClassName('vector-toc-level-1');
for(var listElement of listElements){
listElement.classList.add('vector-toc-list-item-expanded');
}
// avoid bug showing multiple columns for the use of italics
const tocTextElements = document.getElementsByClassName('vector-toc-text');
for(var tocTextElement of tocTextElements){
// put everything after the number into a separate span element
tocTextElement.innerHTML = tocTextElement.innerHTML.replace('</span>', '</span><span>') + '</span>';
}
}
})();
|