Jump to content

User:Jonesey95/AutoEd/replace.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function ReplaceStrings(str) { //MAIN FUNCTION describes list of fixes

  //Replace coauthors with author
//  str = str.replace(/\ +coauthors *=/gi, '\ author =');
  //Replace bad Time magazine ISSN
  str = str.replace(/issn\s*=\s*0040-718X/g, 'issn=0040-781X');
  //Comment out invalid Billboard Brasil ISSN (probably a UPC)
  str = str.replace(/(issn\s*=\s*977-\s*217605400-2\s*\|*)/gi, '<!--$1-->');
  str = str.replace(/(issn\s*=\s*977-2155985400-2)/gi, '<!--$1-->');
  str = str.replace(/(issn\s*=\s*977-879605400-2)/gi, '<!--$1-->');
  //Replace ISSN lower-case x with uppercase X
  str = str.replace(/(issn\s*=\s*\d\d\d\d-*\d\d\d)x/g, '$1X');
  //Fix various ISSN craziness
  str = str.replace(/(issn\s*=\s*\d\d\d\d)=(\d\d\d\d)/gi, '$1-$2');
  str = str.replace(/(issn\s*=\s*\d\d\d\d)–(\d\d\d\d)/gi, '$1-$2');
  str = str.replace(/(issn\s*=\s*\d\d\d\d)—(\d\d\d\d)/gi, '$1-$2');
  //Billboard USA ISSN
  str = str.replace(/issn\s*=\s*0005-*2510/gi, 'issn=0006-2510');
  str = str.replace(/issn\s*=\s*006-*2510/gi, 'issn=0006-2510');
  //Super Play ISSN
  str = str.replace(/issn\s*=\s*0966-*6199/gi, 'issn=0966-6192');

  return str;
}