User:逆襲的天邪鬼/+1s.js: Difference between revisions
m
via Wikiplus
(Created page with "(function () { if (mw.config.get('wgUserGroups').indexOf('sysop') === -1) { return; } var SUMMARY = 'Test +1s by +1s.js...") |
m (via Wikiplus) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4:
}
var SUMMARY = '
document.styleSheets[0].insertRule('.donate1second { color:red; }');
Line 29:
var getUserName = function (item) {
var title = item.getAttribute('title');
if (title.indexOf('/') > -1) {
return null;
}
// deal with markblocked
if (title.indexOf(';') > -1) {
Line 50 ⟶ 55:
block(username).then(function (data) {
if (data.error) {
mw.notify("
} else {
mw.notify("+1s succeeded.");
}
}).fail(function () {
mw.notify("Cannot donate " + username + "'s 1 second.");
}).always(function () {
that.classList.remove('donating1second');
Line 61 ⟶ 68:
$('a[title^="User:"]', '#mw-content-text').each(function (index, item) {
var username = getUserName(item);
if (username) {
var x = $('<a href="#"
.
$(item).after(x);
}
});
};
|