Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
$(document).ready(function(){// If on the edit page, and saved data exists, executeif(window.location.href.indexOf('action')>=0&&localStorage.prevnext){// Textbox valuevarwpTextbox1=document.getElementById('wpTextbox1');varwpTextbox1_V=wpTextbox1.value.split("\n");// Variablesvarbrackets=0;varinfobox=false;varprevIncluded=false;varnextIncluded=false;varprevnext=JSON.parse(localStorage.prevnext);// Iterate through each linefor(vari=0;i<wpTextbox1_V.length;i++){varline=wpTextbox1_V[i];// Check if in infobox or at end of it couting open/closing double curly bracketsif(line.toLowerCase().indexOf("infobox")>=0)infobox=true;if(line.toLowerCase().indexOf("{{")>=0)brackets+=line.match(/\{\{/g).length;if(line.toLowerCase().indexOf("}}")>=0)brackets-=line.match(/\}\}/g).length;if(infobox){// If |prev= or |next= already exist with non-empty entries, take note of thisif(line.match(/\|\s*prev\s*\=\s*(.+)/))prevIncluded=true;if(line.match(/\|\s*next\s*\=\s*(.+)/))nextIncluded=true;// Remove |season_list= and empty |prev= and |next=line=line.replace(/\s*\|\s*season_list\s*=(.*)/g,'');if(!prevIncluded)line=line.replace(/\s*\|\s*prev\s*\=(.*)/g,'');if(!nextIncluded)line=line.replace(/\s*\|\s*next\s*\=(.*)/g,'');// End of infoboxif(brackets===0){// Split line into infobox content and }} if }} isn't on a new linevarline1;varline2;if(line.indexOf("}}")>=0){line1=line.substr(0,line.indexOf("}}"));line2=line.substr(line.indexOf("}}"));}else{line1="";line2=line;}// If no |next=, add it, then set include-parameter to trueif(!nextIncluded){line2=prevnext[1]+line2;nextIncluded=true;}// If no |prev=, add it, then set include-parameter to trueif(!prevIncluded){line2=prevnext[0]+line2;prevIncluded=true;}// Remerge lines, and end infoboxline=line1+(line1?"\n":"")+line2;infobox=false;}}// Save linewpTextbox1_V[i]=line;}// Clear saved datalocalStorage.prevnext='';// Update infoboxvarwpTextbox1NewValue='';varinfobox2=true;for(i=0;i<wpTextbox1_V.length;i++){if(!infobox2||(infobox2&&wpTextbox1_V[i]))wpTextbox1NewValue+=wpTextbox1_V[i]+"\n";if(wpTextbox1_V[i].trim().substr(-3)=="\n}}")infobox2=false;}wpTextbox1.value=wpTextbox1NewValue;// Add summary and alertdocument.getElementById('wpSummary').value+="Replaced deprecated season_list with prev/next via [[User:Alex 21/script-seasonlist|script]].";alert("Completed!");}});$(function($){setTimeout(function(){$.when(mw.loader.using(['mediawiki.util']),$.ready).then(function(){varportletlink=mw.util.addPortletLink('p-tv','#','Remove season list');$(portletlink).click(function(e){e.preventDefault();// Not on editing pageif(window.location.href.indexOf('action')<0){// VariablesvarprevL='';varnextL='';varprevN='';varnextN='';// Find season listvarnoprint=document.getElementsByClassName('noprint');vark=0;while(noprint[k].tagName!="TR")k++;varNavContent=noprint[k].getElementsByTagName('OL')[0].children;// Iterate through the elements of season listfor(vari=0;i<NavContent.length;i++){// Current articleif(NavContent[i].children[0].className.indexOf('selflink')>=0){console.log(NavContent[i].children[0]);// Previous episodeif(NavContent[i-1]){prevL=NavContent[i-1].children[0].title;prevN=NavContent[i-1].children[0].innerHTML;}// Next episodeif(NavContent[i+1]){nextL=NavContent[i+1].children[0].title;nextN=NavContent[i+1].children[0].innerHTML;}}}// Data to savevarprevnext=[];prevnext[0]=("| prev = "+(prevL?(prevL==prevN?"[["+prevL+"]]":"[["+prevL+"|"+prevN+"]]"):"")+"\n").replace(/\[\[\]\]/g,'');prevnext[1]=("| next = "+(nextL?(nextL==nextN?"[["+nextL+"]]":"[["+nextL+"|"+nextN+"]]"):"")+"\n").replace(/\[\[\]\]/g,'');localStorage.prevnext=JSON.stringify(prevnext);// Missing episodes due to previous season finale/next season premiere not being linkedif(!prevL)alert("Previous link missing! Premiere episode? Manual entry required.");if(!nextL)alert("Next link missing! Finale episode? Manual entry required.");// Direct to editing page to automatically execute editswindow.location=window.location.href.substr(0,window.location.href.indexOf('#'))+"?action=edit";}});});},500);});