User:Theleekycauldron/Scripts/PSHAW/dependencies/Hook.js: Difference between revisions

Content deleted Content added
changed func
def capitalize
 
(10 intermediate revisions by the same user not shown)
Line 12:
copies or substantial portions of the Software.
*/
function capitalize(string) {
 
return string.charAt(0).toUpperCase() + string.slice(1);
}
class Hook {
constructor(id,content,credits){
Line 18 ⟶ 20:
this.content = content;
this.articles = []
for (let m of this.content.matchAll(/'''[^']*?\[\[([^\]\|]+)[^\]]*\]\][^']*?'''|\[\[.*'''([^']+)'''\]\]/g)){
this.articles.push(capitalize(m[1]))
}
this.credits = credits
Line 35 ⟶ 37:
}
return "<b>"+this.id+"</b>: "+t.slice()
}
async subpage(){ //returns as Nomination object
if (this.credits.length>0){
let nomination = await Nomination.create(`Template:Did you know nominations/${this.credits[0].subpage}`);
return nomination;
}
return null
}
Line 57 ⟶ 67:
action: 'edit',
title: `User talk:${credit.user}`,
summary: `Giving credit for ${credit.article}`+tag,
section: 'new',
sectiontitle: `DYK for ${credit.article}`,
Line 73 ⟶ 83:
get_section(`Talk:${article}`,0).then((talk) => {
console.log(talk)
let talktext = talk.parse.wikitext + `\n${res}`
console.log(talktext)
var params = {
action: 'edit',
title: `Talk:${article}`,
summary: `Article appeared on [[WP:DYK|DYK]] on ${today}, adding {{[[Template:DYK talk|DYK talk]]}}`+tag,
section: '0',
text: talktext,
format: 'json'
}
//return api.postWithToken( 'csrf', params );
})
}
}
// </nowiki>