59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
if (!window.location.href.match(/\/entry\//)) return;
|
|
|
|
function styleAutoSummaries() {
|
|
const content = document.querySelector('.entry-content');
|
|
if (!content) return;
|
|
|
|
// Find all paragraphs that contain RÉSUMÉ AUTO
|
|
const allElements = content.querySelectorAll('*');
|
|
|
|
allElements.forEach(element => {
|
|
if (element.textContent.includes('RÉSUMÉ AUTO') && !element.dataset.processed) {
|
|
// Find the actual container (could be this element or a parent)
|
|
let container = element;
|
|
while (container && !['P', 'DIV', 'ARTICLE'].includes(container.tagName)) {
|
|
container = container.parentElement;
|
|
}
|
|
|
|
if (container) {
|
|
container.dataset.processed = 'true';
|
|
|
|
// Style the whole fucking container
|
|
Object.assign(container.style, {
|
|
margin: '12px 0',
|
|
padding: '10px',
|
|
background: 'rgb(51 85 67)',
|
|
borderLeft: '3px solid rgb(71 180 103)',
|
|
fontFamily: 'Geist Mono',
|
|
whiteSpace: 'pre-wrap'
|
|
});
|
|
|
|
// Clean and add header
|
|
container.innerHTML = container.innerHTML
|
|
.replace(/---\s*RÉSUMÉ AUTO\s*---/gi, '')
|
|
.replace(/^\s*RÉSUMÉ AUTO\s*/gi, '');
|
|
|
|
const header = document.createElement('div');
|
|
header.textContent = 'RÉSUMÉ AUTO';
|
|
Object.assign(header.style, {
|
|
fontWeight: 'bold',
|
|
marginBottom: '8px',
|
|
color: 'rgb(71 180 103)',
|
|
fontSize: '0.9em'
|
|
});
|
|
|
|
container.insertBefore(header, container.firstChild);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'complete') {
|
|
styleAutoSummaries();
|
|
} else {
|
|
window.addEventListener('load', styleAutoSummaries);
|
|
}
|
|
})(); |