Skip to content

Commit 1e6ffd1

Browse files
committed
Added optional chaining ot XF check, shortened styleNode to style, eliminated css init, replaced .appendChild() w/ .append()
1 parent 81437fb commit 1e6ffd1

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

hide-forum-images/hide-forum-images.user.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Hide Forum Images
3-
// @version 2025.10.19.1
3+
// @version 2025.10.19.2
44
// @author Adam Lui
55
// @namespace https://adamlui.com
66
// @description Hides images/videos from XenForo, vBulletin & Discourse forums.
@@ -23,10 +23,11 @@
2323
(() => {
2424
'use strict'
2525
if (document.querySelector('[src*="vbulletin"], [src*="discourse"]')
26-
|| /xenforo/i.test(document.querySelector('.copyright').textContent)
26+
|| /xenforo/i.test(document.querySelector('.copyright')?.textContent)
2727
) {
28-
const css = 'img, [style*="background-image"], [class*="avatar"], [class*="player"] { display:none !important; }'
29-
const styleNode = document.createElement('style') ; styleNode.innerText = css
30-
document.head.appendChild(styleNode)
28+
const style = document.createElement('style')
29+
style.textContent = `img, [style*="background-image"], [class*="avatar"], [class*="player"] {
30+
display:none !important }`
31+
document.head.append(style)
3132
}
3233
})()

0 commit comments

Comments
 (0)