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

Content deleted Content added
gotcha, bastard
underscores
 
(30 intermediate revisions by the same user not shown)
Line 12:
copies or substantial portions of the Software.
*/
 
 
 
class Nomination {
constructor(title,page){
this.title = title.replaceAll("_"," "); //MediaWiki stuff
this.page = respage
get_pages(this.title,"user|content",null,"older").then((res) => {
this.content = this.page[0].revisions[0].slots.main.content;
this.page = res
this.isHatted = this.content.includes("'''No further edits should be made to this page'''.")
this.content = this.page[0].revisions[0].slots.main.content;
this.isApproved = this.content.includes("[[File:Symbol_voting_keep.svg|16px]]") || this.content.includes("[[File:Symbol voting keep.svg|16px]]") || this.content.includes("[[File:Symbol_confirmed.svg|16px]]") || this.content.includes("[[File:Symbol confirmed.svg|16px]]") || this.content.match(/\|.*?status.*?=.*?y/g) != undefined
this.isHatted = this.content.includes("'''No further edits should be made to this page'''.")
this.alphanumericals="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
this.isApproved = this.content.includes("[[File:Symbol voting keep.svg|16px]]") || this.content.includes("[[File:Symbol confirmed.svg|16px]]") || this.content.match(/\|.*?status.*?=.*?y/g) != undefined
this.alphanumericals="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
this.loadHooks();
this.loadFiles();
});
}
static async create(title){
title = title.replaceAll("_"," "); //MediaWiki stuff
let page = await get_pages(this.title,"user|content",null,"older").then((res) => {;
let nom = new Nomination(title,page)
thisnom.loadHooks();
thisnom.loadFiles();
return nom
}
 
hasBeenEditedByUser(){
Line 39 ⟶ 47:
splittext[0] = "{{subst:DYKsubpage";
splittext[2] = "|passed="+type;
//console.log(topmessage)
if (topmessage != ""){
splittext.splice(4,0,topmessage);
Line 56 ⟶ 64:
unhat(prep){
console.log(this.page[0])
for (let revision of this.page[0].revisions){
let revtext = revision.slots.main.content;
if (revtext.includes("{{DYKsubpage")){
this.content = revtext;
Line 65 ⟶ 74:
}
async retransclude(){
let res = await get_pages("Template talk:Did you know","user|content",null,"older").then((res) => {;
let dykn = res[0].revisions[0].slots.main.content.split("\n");
for (var i=0; i<dykn.length; i++){
i = 0
if (linedykn[i].includes("===Articles created/expanded on")){
for (let line of dykn){
dykn.splice(i+2,0,`{{${this.title}}}`)
if (line.includes("===Articles created/expanded on")){
dykn.splice( = dykn.indexjoin(line)+2,0,`{{${this.title}}}`"\n")
dyknlet params = dykn.join("\n"){
letaction: params = {'edit',
title: "Template talk:Did you know",
action: 'edit',
summary: `Retranscludingretranscluding [[${this.title}]]`+tag,
title: "Template talk:Did you know",
text: dykn,
summary: `Retranscluding [[${this.title}]]`,
textformat: dykn,'json'
format: 'json'
}
return api.postWithToken( 'csrf', params );
}
return api.postWithToken( 'csrf', params );
}
})
}
loadHooks(){
this.hooks = []
//console.log(this.content)
let credits = this.content.match(/\* \{\{DYK(make|nom).*?\}\}/g);
if (credits == null){
Line 94 ⟶ 101:
}
let hooktext = this.content.match(/('''ALT.+?)?(\.\.\..*?)(?:{{-\?}}|\?)/g);
//console.log(hooktext)
let u=0;
for (let hook of hooktext){