User:DR/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
importScript('User:DR/UserInfoEN.js'); // Backlink: [[User:DR/UserInfoEN.js]]
importScript('User:DR/UserInfoEN.js'); // Backlink: [[User:DR/UserInfoEN.js]]
// <nowiki>
(function() {
(function() {
'use strict';
'use strict';
const config = window.clearDeleteReasonConfig || { applyOnlyOnMobile: true };
if (window.location.search.includes('action=delete')) {

var observer = new MutationObserver(function(mutations) {
if (window.location.search.includes('action=delete') && (!config.applyOnlyOnMobile || /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent))) {
// window.addEventListener('load', function() {
// const reasonInput = document.querySelector('input[name="wpReason"]');
// if (reasonInput) {
// reasonInput.value = '';
// }
// });
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
if (mutation.addedNodes.length) {
var reasonInput = document.querySelector('input[name="wpReason"]');
const reasonInput = document.querySelector('input[name="wpReason"]');
if (reasonInput) {
if (reasonInput) {
reasonInput.value = '';
reasonInput.value = '';
Line 18: Line 27:
}
}
})();
})();
// </nowiki>

Revision as of 11:01, 14 March 2025

importScript('User:DR/UserInfoEN.js'); // Backlink: [[User:DR/UserInfoEN.js]]
// <nowiki>
(function() {
    'use strict';
    const config = window.clearDeleteReasonConfig || { applyOnlyOnMobile: true };

    if (window.location.search.includes('action=delete') && (!config.applyOnlyOnMobile || /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent))) {
        // window.addEventListener('load', function() {
        //     const reasonInput = document.querySelector('input[name="wpReason"]');
        //     if (reasonInput) {
        //         reasonInput.value = '';
        //     }
        // });
        const observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (mutation.addedNodes.length) {
                    const reasonInput = document.querySelector('input[name="wpReason"]');
                    if (reasonInput) {
                        reasonInput.value = '';
                        observer.disconnect();
                    }
                }
            });
        });

        observer.observe(document.body, { childList: true, subtree: true });
    }
})();
// </nowiki>