m (Automatically syncing global gadgets across wikis) |
m (Automatically syncing global gadgets across wikis) |
||
Line 20: | Line 20: | ||
}); |
}); |
||
+ | /* copy titles from search, recentchanges, contribs */ |
||
$(function() { |
$(function() { |
||
+ | var selectors = [ |
||
− | if (mw.config.get('wgTitle') != 'Search') return; |
||
+ | { pattern: 'Special:Search', selector: '.unified-search__result__title', attr: 'data-title' }, |
||
⚫ | |||
+ | { pattern: 'Special:Contributions/', selector: '.mw-contributions-title', attr: 'title' }, |
||
⚫ | |||
+ | { pattern: 'Special:RecentChanges', selector: '.mw-changeslist-line-inner .mw-title a', attr: 'title' }, |
||
− | $('.mw-search-result-heading a:first-of-type').each(function() { |
||
+ | ]; |
||
⚫ | |||
+ | var pageName = mw.config.get('wgPageName'); |
||
+ | for (i in selectors) { |
||
+ | if (!pageName.includes(selectors[i].pattern)) continue; |
||
⚫ | |||
⚫ | |||
+ | $(selectors[i].selector).each(function() { |
||
⚫ | |||
+ | }); |
||
⚫ | |||
⚫ | |||
}); |
}); |
||
+ | // don't let i keep incrementing |
||
⚫ | |||
+ | return; |
||
⚫ | |||
− | } |
+ | } |
}); |
}); |
Latest revision as of 05:28, 1 September 2021
$(function() {
wgNamespace = mw.config.get('wgCanonicalNamespace');
if (wgNamespace != 'Category') return;
$(mw.util.addPortletLink('p-cactions', 'javascript:;', '!Copy Members', 'ca-copy-cat-members', 'Copy Category Members', null, '#ca-move-to-user')).click(function() {
a = new mw.Api();
a.get({
action : 'query',
list : 'categorymembers',
cmtitle : mw.config.get('wgPageName'),
cmlimit : 'max'
}).then(function(data) {
tbl = [];
for (page in data.query.categorymembers) {
tbl.push(data.query.categorymembers[page].title);
}
var str = tbl.join('\n');
displayOutputText(str, true);
});
});
});
/* copy titles from search, recentchanges, contribs */
$(function() {
var selectors = [
{ pattern: 'Special:Search', selector: '.unified-search__result__title', attr: 'data-title' },
{ pattern: 'Special:Contributions/', selector: '.mw-contributions-title', attr: 'title' },
{ pattern: 'Special:RecentChanges', selector: '.mw-changeslist-line-inner .mw-title a', attr: 'title' },
];
var pageName = mw.config.get('wgPageName');
for (i in selectors) {
if (!pageName.includes(selectors[i].pattern)) continue;
$(mw.util.addPortletLink('p-cactions', 'javascript:;', '!Copy Titles', 'ca-copy-search-results', 'Copy Titles', null, '#ca-move-to-user')).click(function() {
var pageList = [];
$(selectors[i].selector).each(function() {
pageList.push($(this).attr(selectors[i].attr));
});
var str = pageList.join('\n');
displayOutputText(str, true);
});
// don't let i keep incrementing
return;
}
});