"मीडियाविकि:Common.js": अवतरणों में अंतर
Arisepedia (वार्ता | योगदान) ('→यहाँ दी गई जावास्क्रिप्ट सभी सदस्यों के लिए हमेशा लोड की जाएगी: // Prevent right-click, double-click, and text selection (function () { // Disable right-click everywhere document.addEventListener('contextmenu', function (e) { e.preventDefault(); }); // Prevent text selection start document.addEventListener('sel...' के साथ नया पृष्ठ बनाया) |
Arisepedia (वार्ता | योगदान) No edit summary |
||
| पंक्ति १: | पंक्ति १: | ||
/* यहाँ दी गई जावास्क्रिप्ट सभी सदस्यों के लिए हमेशा लोड की जाएगी */ | /* यहाँ दी गई जावास्क्रिप्ट सभी सदस्यों के लिए हमेशा लोड की जाएगी */ | ||
// | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// Public-only copy deterrent; admins/editors unaffected | |||
(function () { | (function () { | ||
// Disable right-click | 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) { | document.addEventListener('contextmenu', function (e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
}); | }, { capture: true }); | ||
// Prevent | // Prevent starting a selection (keeps links clickable) | ||
document.addEventListener('selectstart', function (e) { | 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(); | e.preventDefault(); | ||
}); | }, { capture: true }); | ||
// Block double | // Block double/triple click selection | ||
document.addEventListener('mousedown', function (e) { | document.addEventListener('mousedown', function (e) { | ||
if (e.detail > 1) | // left/right clicks still work; we only block multi-click selection | ||
if (e.detail > 1) e.preventDefault(); | |||
}, { capture: true }); | |||
})(); | })(); | ||
१३:५९, १२ अक्टूबर २०२५ का अवतरण
/* यहाँ दी गई जावास्क्रिप्ट सभी सदस्यों के लिए हमेशा लोड की जाएगी */
/* 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 });
})();