Content deleted Content added
removeBorderFromImagesInInfoboxes() -> album cover (publish.php) |
moveAFCSubmissionTemplatesToTop(), deleteNonAFCDraftTags(), refactor (publish.php) |
||
Line 1:
// <nowiki>
// === Compiled with Novem Linguae's publish.php script ======================
$(async function() {
// === main.js ======================================================
/* THIS SCRIPT IS STILL IN BETA AND IS BUGGY ABOUT 25% OF THE TIME. Be sure to check the diff that pops up before submitting.▼
▲/* THIS SCRIPT
- Adds "Run DraftCleaner" link to the left sidebar
Line 176 ⟶ 180:
}
});
// === modules/DraftCleaner.js ======================================================
Line 182 ⟶ 188:
// run before other stuff
wikicode = this.deleteSomeHTMLTags(wikicode);
wikicode = this.
wikicode = this.fixWikilinksContainingURL(wikicode);
Line 218 ⟶ 224:
wikicode = this.removeBorderFromImagesInInfoboxes(wikicode);
wikicode = this.removeExtraAFCSubmissionTemplates(wikicode);
wikicode = this.moveAFCSubmissionTemplatesToTop(wikicode);
// all ==sections== should start with a capital letter
Line 640 ⟶ 647:
wikicode = wikicode.replace(/<\/?nowiki( [^>]*)?\/?>/g, '');
wikicode = wikicode.replace(/<\/?u( [^>]*)?\/?>/g, '');
return wikicode;
}▼
deleteNonAFCDraftTags(wikicode) {
wikicode = wikicode.replace(/{{Preloaddraft submit}}\n{0,2}/gi, '');
wikicode = wikicode.replace(/<!-- When you move this draft into article space, please link it to the Wikidata entry and remove the QID in the infobox code\. -->\n{0,2}/gi, '');
wikicode = wikicode.replace(/{{Draft}}\n{0,2}/gi, '');
return wikicode;
}
Line 664 ⟶ 679:
return wikicode;
▲ }
▲ return wikicode.replace(/(?:<big>|<\/big>)/g, '');
}
Line 710 ⟶ 721:
if ( hasSubmittedTemplate && hasUnsubmittedTemplate ) {
wikicode = wikicode.replace(/{{AfC submission\|t\|[^\}\}]*\}\}\n?/gm, '');
}
return wikicode;
}▼
moveAFCSubmissionTemplatesToTop(wikicode) {
let hasTemplateAtBottom = wikicode.match(/\n[^\n]+\n*({{AfC submission[^\}]*}})\s*$/i);
if ( hasTemplateAtBottom ) {
// delete all submission templates
wikicode = wikicode.replace(/{{AfC submission[^\}\}]*\}\}\n?/gm, '');
// insert template at top
wikicode = hasTemplateAtBottom[1] + "\n\n" + wikicode;
}
return wikicode;
Line 733 ⟶ 756:
}
// === modules/StringFilter.js ======================================================
/** Lets you use regex to specify what parts of a very long string you want to specify as "off limits", then you can do additional regex's and search/replace to the remaining parts of the string. */▼
/**
▲
*/
class StringFilter {
/**
*/
surgicalReplaceOutsideTags(regex, replacement, haystack, openingTags, closingTags) {
let allTags = [...openingTags, ...closingTags];
Line 756 ⟶ 785:
}
/**
*/
surgicalReplaceInsideTags(regex, replacement, haystack, openingTags, closingTags) {
let allTags = [...openingTags, ...closingTags];
Line 773 ⟶ 804:
/**
* @returns {string[]}
▲ @param {Array} patterns
_splitStringUsingMultiplePatterns(string, patterns) {
let length = string.length;
|