User:Guywan/Scripts/InsertShortcuts.js: Difference between revisions

Content deleted Content added
mNo edit summary
maintenance: more info wikitext is array. startsWith is a string method.
 
(3 intermediate revisions by 2 users not shown)
Line 33:
this.getWikitext(page, wikitext =>
{
if(typeof wikitext === 'string' && wikitext.startsWith("!!REDIRECT"))
{
project = wikitext.split(" ")[1];
Line 39:
{
// Remove escaped newlines. Escape 'comments'. Split into tags.
this.inserts = wikitext.replace(/\\\n/g, "").replace(/^\/\//gm, "").split("\n");
}, null, null, `https://${project}.org/w/api.php`);
Line 46:
{
// Remove escaped newlines. Escape 'comments'. Split into tags.
this.inserts = wikitext.replace(/\\\n/g, "").replace(/^\/\//gm, "").split("\n");
}
}, null, null, loadFrom);
Line 98:
for(var id in data.query.pages)
{
wikitext.push(var revisions = data.query.pages[id].revisions || [0].slots.main['*']);
if(revisions.length) wikitext.push(revisions[0].slots.main['*']);
}