|
|
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Any JavaScript here will be loaded for all users on every page load. */ |
| // Public-only copy deterrent; admins/editors unaffected
| |
| (function () {
| |
| var action = mw.config.get('wgAction'); // 'view', 'edit', etc.
| |
| var groups = mw.config.get('wgUserGroups') || [];
| |
|
| |
| // Define who should be exempt (enable/trim as you like)
| |
| var isPrivileged =
| |
| groups.includes('sysop') ||
| |
| groups.includes('bureaucrat') ||
| |
| groups.includes('interface-admin') ||
| |
| groups.includes('editor') || // remove if you don't have this group
| |
| groups.includes('patroller'); // remove if you don't use this
| |
|
| |
| // Run only on read/view pages and only for non-privileged users
| |
| if (action !== 'view' || isPrivileged) return;
| |
|
| |
| // Mark page so CSS activates only for these users
| |
| document.documentElement.classList.add('no-copy');
| |
|
| |
| // Disable right-click (admins are exempt above)
| |
| document.addEventListener('contextmenu', function (e) {
| |
| e.preventDefault();
| |
| }, { capture: true });
| |
|
| |
| // Prevent starting a selection (keeps links clickable)
| |
| document.addEventListener('selectstart', function (e) {
| |
| // Allow in fields/editable areas just in case
| |
| var t = e.target;
| |
| var tag = (t.tagName || '').toLowerCase();
| |
| if (tag === 'input' || tag === 'textarea' || t.isContentEditable || (t.closest && t.closest('#wpTextbox1'))) {
| |
| return;
| |
| }
| |
| e.preventDefault();
| |
| }, { capture: true });
| |
|
| |
| // Block double/triple click selection
| |
| document.addEventListener('mousedown', function (e) {
| |
| // left/right clicks still work; we only block multi-click selection
| |
| if (e.detail > 1) e.preventDefault();
| |
| }, { capture: true });
| |
| })();
| |