MediaWiki:Common.js: различия между версиями
Kerisar (обсуждение | вклад) мНет описания правки |
Kerisar (обсуждение | вклад) мНет описания правки |
||
| Строка 245: | Строка 245: | ||
} | } | ||
const addedStyles = new Set(); | |||
function customCSS(textCSS) { | function customCSS(textCSS) { | ||
const escapedCSS = escapeAndMinifyCSS(textCSS); // Экранируем CSS | const escapedCSS = escapeAndMinifyCSS(textCSS); // Экранируем CSS | ||
const styleSheet = document.createElement("style"); | |||
// Проверяем, был ли уже добавлен этот CSS | |||
if (!addedStyles.has(escapedCSS)) { | |||
addedStyles.add(escapedCSS); // Добавляем в множество уникальных стилей | |||
const styleSheet = document.createElement("style"); | |||
styleSheet.textContent = escapedCSS; | |||
document.head.appendChild(styleSheet); | |||
} | |||
} | } | ||