User:Techhead55/common.js

importScript('User:TheDJ/sharebox.js'); importScript('User:Techhead55/testing.js'); function getTVData(url){ var tvxhr = new XMLHttpRequest, data; tvxhr.open("GET", url, false); tvxhr.onload = function{ data = { seasons: tvxhr.responseText.match("No. of seasons") === null ? tvxhr.responseText.split("No. of series \n ")[1].split(" ")[0].split(" (")[0] :               tvxhr.responseText.split("No. of seasons \n ")[1].split(" ")[0].split(" (")[0], episodes: tvxhr.responseText.split("No. of episodes \n ")[1].split(" ")[0].split(" ")[0], runtime: tvxhr.responseText.split("Original run \n ")[1].split(" ")[0], imgURL: tvxhr.responseText.split("<img ")[1].split('src="')[1].split('"')[0] };	};	tvxhr.send; return data; } if (document.getElementById("firstHeading").childNodes[0].innerText==="User:Techhead55/Favourite Science Fiction Series"){ document.getElementsByClassName("wikitable")[0].style.width = "100%"; Array.prototype.slice.call(document.getElementsByClassName("wikitable")[0].tBodies[0].rows).slice(1).forEach(function(v, i, e){       var data = getTVData(v.children[0].children[0].href),            seasons = document.createElement("td"),            episodes = document.createElement("td"),            runtime = document.createElement("td"),            cover = document.createElement("img");        seasons.innerHTML = data.seasons;        seasons.style.textAlign = "center";        episodes.innerHTML = data.episodes;        episodes.style.textAlign = "center";        runtime.innerHTML = data.runtime;        runtime.style.textAlign = "center";        cover.src = data.imgURL;        e[i].appendChild(cover);        e[i].appendChild(seasons);        e[i].appendChild(episodes);        e[i].appendChild(runtime);    }); }