Temp disabling to debug Tags: Replaced Reverted |
Restored revision 563851 (AntiVandal) Tag: Manual revert |
||
| Line 1: | Line 1: | ||
< | mw.loader.using(['mediawiki.util']).then(function () { | ||
if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') === -1 && | |||
mw.config.get('wgUserGroups').indexOf('confirmed') === -1) { | |||
return; | |||
} | |||
var ITEMS = [ | |||
{ id: 'twinkle-tag', label: 'Tag', icon: 'ri-price-tag-3-line' }, | |||
{ id: 'twinkle-csd', label: 'CSD', icon: 'ri-delete-bin-6-line' }, | |||
{ id: 'twinkle-warn', label: 'Warn', icon: 'ri-alarm-warning-line' }, | |||
{ id: 'twinkle-block', label: 'Block', icon: 'ri-user-unfollow-line' }, | |||
{ id: 'twinkle-protect', label: 'Protect', icon: 'ri-shield-line' }, | |||
{ id: 'twinkle-unlink', label: 'Unlink', icon: 'ri-link-unlink' }, | |||
{ id: 'twinkle-xfd', label: 'XfD', icon: 'ri-chat-delete-line' }, | |||
{ id: 'twinkle-lastdiff', label: 'Last diff', icon: 'ri-git-branch-line' } | |||
]; | |||
function ready() { | |||
if (document.getElementById('bpneo-tw-wrap')) { | |||
return true; | |||
} | |||
if (typeof Twinkle !== 'object') { | |||
return false; | |||
} | |||
var bar = document.querySelector('.bpneo-title-actions'); | |||
if (!bar) { | |||
return false; | |||
} | |||
var wrap = document.createElement('div'); | |||
wrap.id = 'bpneo-tw-wrap'; | |||
wrap.className = 'bpneo-action-wrap'; | |||
wrap.style.position = 'relative'; | |||
var btn = document.createElement('button'); | |||
btn.type = 'button'; | |||
btn.className = 'bpneo-title-btn'; | |||
btn.title = 'Twinkle'; | |||
btn.innerHTML = '<i class="ri-sparkling-2-line"></i>'; | |||
var menu = document.createElement('div'); | |||
menu.id = 'bpneo-tw-menu'; | |||
menu.className = 'bpneo-action-menu'; | |||
menu.style.display = 'none'; | |||
var added = 0; | |||
ITEMS.forEach(function (item) { | |||
var src = document.getElementById(item.id); | |||
if (!src) { | |||
return; | |||
} | |||
var a = document.createElement('a'); | |||
a.href = '#'; | |||
a.innerHTML = '<i class="' + item.icon + '"></i> ' + item.label; | |||
a.addEventListener('click', function (e) { | |||
e.preventDefault(); | |||
menu.style.display = 'none'; | |||
src.click(); | |||
}); | |||
menu.appendChild(a); | |||
added++; | |||
}); | |||
if (!added) { | |||
return false; | |||
} | |||
btn.addEventListener('click', function (e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
menu.style.display = menu.style.display === 'none' ? 'block' : 'none'; | |||
}); | |||
document.addEventListener('click', function (e) { | |||
if (!wrap.contains(e.target)) { | |||
menu.style.display = 'none'; | |||
} | |||
}); | |||
wrap.appendChild(btn); | |||
wrap.appendChild(menu); | |||
bar.appendChild(wrap); | |||
return true; | |||
} | |||
var n = 0; | |||
var t = setInterval(function () { | |||
n++; | |||
if (ready()) { | |||
clearInterval(t); | |||
} | |||
if (n > 60) { | |||
clearInterval(t); | |||
} | |||
}, 250); | |||
}); | |||
Latest revision as of 21:44, 16 October 2026
mw.loader.using(['mediawiki.util']).then(function () {
if (mw.config.get('wgUserGroups').indexOf('autoconfirmed') === -1 &&
mw.config.get('wgUserGroups').indexOf('confirmed') === -1) {
return;
}
var ITEMS = [
{ id: 'twinkle-tag', label: 'Tag', icon: 'ri-price-tag-3-line' },
{ id: 'twinkle-csd', label: 'CSD', icon: 'ri-delete-bin-6-line' },
{ id: 'twinkle-warn', label: 'Warn', icon: 'ri-alarm-warning-line' },
{ id: 'twinkle-block', label: 'Block', icon: 'ri-user-unfollow-line' },
{ id: 'twinkle-protect', label: 'Protect', icon: 'ri-shield-line' },
{ id: 'twinkle-unlink', label: 'Unlink', icon: 'ri-link-unlink' },
{ id: 'twinkle-xfd', label: 'XfD', icon: 'ri-chat-delete-line' },
{ id: 'twinkle-lastdiff', label: 'Last diff', icon: 'ri-git-branch-line' }
];
function ready() {
if (document.getElementById('bpneo-tw-wrap')) {
return true;
}
if (typeof Twinkle !== 'object') {
return false;
}
var bar = document.querySelector('.bpneo-title-actions');
if (!bar) {
return false;
}
var wrap = document.createElement('div');
wrap.id = 'bpneo-tw-wrap';
wrap.className = 'bpneo-action-wrap';
wrap.style.position = 'relative';
var btn = document.createElement('button');
btn.type = 'button';
btn.className = 'bpneo-title-btn';
btn.title = 'Twinkle';
btn.innerHTML = '<i class="ri-sparkling-2-line"></i>';
var menu = document.createElement('div');
menu.id = 'bpneo-tw-menu';
menu.className = 'bpneo-action-menu';
menu.style.display = 'none';
var added = 0;
ITEMS.forEach(function (item) {
var src = document.getElementById(item.id);
if (!src) {
return;
}
var a = document.createElement('a');
a.href = '#';
a.innerHTML = '<i class="' + item.icon + '"></i> ' + item.label;
a.addEventListener('click', function (e) {
e.preventDefault();
menu.style.display = 'none';
src.click();
});
menu.appendChild(a);
added++;
});
if (!added) {
return false;
}
btn.addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
menu.style.display = menu.style.display === 'none' ? 'block' : 'none';
});
document.addEventListener('click', function (e) {
if (!wrap.contains(e.target)) {
menu.style.display = 'none';
}
});
wrap.appendChild(btn);
wrap.appendChild(menu);
bar.appendChild(wrap);
return true;
}
var n = 0;
var t = setInterval(function () {
n++;
if (ready()) {
clearInterval(t);
}
if (n > 60) {
clearInterval(t);
}
}, 250);
});