User:JAAqqO/own.js

function autoEdOwn (str) { str = str.replace(/archivedate/g, "archive-date")

.replace(/archiveurl/g, "archive-url")

.replace(/accessdate/g, "access-date")

.replace(//g, "")

.replace(/\[\[[Ii]mage:/g, "[[File:")

.replace(/\([Ii]n [Ff]innish\)/g, "")

.replace(/\{\{IPA-fi\|/g, "{{IPA|fi|")

.replace(/=[^\*] *\{\{([Tt]emplate:)?[Cc]ommons[- ]*[Cc]at(egory)?[- ]*[Ii]nline/, "=\n* {{Commons category-inline")

.replace(/(=|\}\})[^\*] *\{\{([Tt]emplate:)?([Ww]ikivoyage-inline|[Ww]ikivoyage inline)/, "$1\n* {{$3")

.replace(/\]\]\n*(\{\{[0-9a-zA-Z\-]*[Ss]tub\}\})/, "]]\n\n\n$1")

.replace(/\{\{finland/g, "{{Finland")

.replace(/\[(http[^ ]+) Official website\]/, "{{Official website|$1}}")

.replace(/(\n[-A-ZÄÖåa-zäöå ]+)( ")([-A-ZÄÖåa-zäöå ]+)(" )([-A-ZÄÖåa-zäöå ]+ )/, "$1$2$3$4$5")

.replace(/([^\n])\n+(\{\{DEFAULTSORT:.+\[\[[Cc]ategory:[0-9]+ (births|deaths))/s, "$1\n\n{{Authority control}}JAAqqOauth\n\n$2")

.replace(/(\{\{([Aa](uthority|CArt)|[Ee]xternal identifiers).+)\{\{Authority control\}\}JAAqqOauth\n\n/s, "$1")

.replace(/\}\}\n(\n\{\{Authority control\}\}JAAqqOauth)/, "}}$1")

.replace(/\}JAAqqOauth/, "}")

.replace(/ +\(([0-9]{3,4}) *[-–—] *([0-9]{3,4})\)/, " \($1–$2\)")

.replace(/(\n(\* *\{\{[^\}]+|\{\{[Rr]eflist.*)\}\}\n)(\{\{[Aa]uthority control)/, "$1\n$3")

.replace(/([0-9]{4}) *- *present/g, "$1–present")

.replace(/\{\{[Ii]nfobox Former Subdivision/g, "{{Infobox former subdivision")

.replace(/\{\{[Uu]rl\|/g, "{{URL|")

.replace(/(\([1-9][0-9]{2,3})\{\{([Tt]emplate:)?([Dd]ash|[Nn]bspndash|[Ss]nd|[Ss]ndash|[Ss]paced en dash|[Ss]paced en-dash|[Ss]paced endash|[Ss]paced ndash|[Ss]pnd|[Ss]pndash)\}\}([1-9][0-9]{2,3}\))/g, "$1–$4")

.replace(/([\.,])[\t ]+[\t ]+<ref")

.replace(/([1-9][0-9]?,? +|(January|February|March|April|May|June|July|August|September|October|November|December) +([1-9][0-9]{2,3} +)?)[—-]( +([1-9][0-9]?,? +|(January|February|March|April|May|June|July|August|September|October|November|December)))/g, "$1–$4")

.replace(/http:\/\/www\.helsinki\.fi\/ylioppilasmatrikkeli\/(1853-1899\/)?henkilo/g, "https://ylioppilasmatrikkeli.fi/$1henkilo");

function JAAqqOrepeat(regex, replacement, times) { for (let i = 0; i < times; i++) { str = str.replace(regex, replacement); } }

JAAqqOrepeat(/(| name[^>\/]+>)[^<]*[Pp]\.[\t 0-9,–\-\.]+)-([0-9])/g, "$1–$3", 10);

JAAqqOrepeat(/(\[\[[Ff]ile:[^\]\|]+)_/g, "$1 ", 10);

JAAqqOrepeat(/(https?:\/\/[^ \|<]+|')’/g, '$1JAAqqOcurly1', 20);

JAAqqOrepeat(/(https?:\/\/[^ \|<]+|')‘/g, '$1JAAqqOcurly2', 20);

JAAqqOrepeat(/(https?:\/\/[^ \|<]+)”/g, '$1JAAqqOcurly3', 20);

JAAqqOrepeat(/(https?:\/\/[^ \|<]+)“/g, '$1JAAqqOcurly4', 20);

JAAqqOrepeat(/’([^\|\n]*\.(djvu|flac|gif|jpe?g|mid|oga|ogg|ogv|opus|pdf|png|svg|tiff|wav|webm|webp|xcf))/gi, 'JAAqqOcurly1$1', 20);

JAAqqOrepeat(/‘([^\|\n]*\.(djvu|flac|gif|jpe?g|mid|oga|ogg|ogv|opus|pdf|png|svg|tiff|wav|webm|webp|xcf))/gi, 'JAAqqOcurly2$1', 20);

JAAqqOrepeat(/”([^\|\n]*\.(djvu|flac|gif|jpe?g|mid|oga|ogg|ogv|opus|pdf|png|svg|tiff|wav|webm|webp|xcf))/gi, 'JAAqqOcurly3$1', 20);

JAAqqOrepeat(/“([^\|\n]*\.(djvu|flac|gif|jpe?g|mid|oga|ogg|ogv|opus|pdf|png|svg|tiff|wav|webm|webp|xcf))/gi, 'JAAqqOcurly4$1', 20);

str = str.replace(/[”“]/g, '"') .replace(/[’‘]/g, "'")

.replace(/JAAqqOcurly1/g, "’") .replace(/JAAqqOcurly2/g, "‘") .replace(/JAAqqOcurly3/g, "”") .replace(/JAAqqOcurly4/g, "“");

return str; } // .replace(//g, "")    OR     .replace(//, "")     OR     .replace(//s, "")