NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Show Useful Info on Requests // @version 1.19 // @author Gazza // @description Converts the values displayed on show request back into the repsective text; i.e Language: 35 --> English // @updateURL https://openuserjs.org/meta/gazza911/Show_Useful_Info_on_Requests.meta.js // @match http://www.tvmaze.com/request/view* // @match https://www.tvmaze.com/request/view* // @grant GM_getValue // @grant GM_setValue // @license MIT // ==/UserScript== // You are required to be logged in if the script needs to update the networks or web channels var networks = GM_getValue("tvmaze_networks", {}); var web_channels = GM_getValue("tvmaze_webchannels", {}); var language = []; { language["1"] = "Abkhazian"; language["2"] = "Afar"; language["3"] = "Afrikaans"; language["4"] = "Akan"; language["5"] = "Albanian"; language["6"] = "Amharic"; language["7"] = "Arabic"; language["8"] = "Armenian"; language["9"] = "Assamese"; language["10"] = "Aymara"; language["11"] = "Azerbaijani"; language["12"] = "Bambara"; language["13"] = "Bashkir"; language["14"] = "Basque"; language["15"] = "Belarusian"; language["16"] = "Bengali"; language["17"] = "Bihari"; language["18"] = "Bosnian"; language["19"] = "Breton"; language["20"] = "Bulgarian"; language["21"] = "Burmese"; language["22"] = "Catalan"; language["23"] = "Central Khmer"; language["24"] = "Chechen"; language["25"] = "Chichewa"; language["26"] = "Chinese"; language["27"] = "Chuvash"; language["28"] = "Corsican"; language["29"] = "Croatian"; language["30"] = "Czech"; language["31"] = "Danish"; language["32"] = "Divehi"; language["33"] = "Dutch"; language["34"] = "Dzongkha"; language["35"] = "English"; language["36"] = "Estonian"; language["37"] = "Ewe"; language["38"] = "Fijian"; language["39"] = "Finnish"; language["40"] = "French"; language["41"] = "Fulah"; language["42"] = "Galician"; language["43"] = "Ganda"; language["44"] = "Georgian"; language["45"] = "German"; language["46"] = "Greek"; language["47"] = "Greenlandic"; language["48"] = "Guarani"; language["49"] = "Gujarati"; language["50"] = "Haitian"; language["51"] = "Hausa"; language["52"] = "Hebrew"; language["53"] = "Herero"; language["54"] = "Hindi"; language["55"] = "Hungarian"; language["56"] = "Icelandic"; language["57"] = "Igbo"; language["58"] = "Indonesian"; language["59"] = "Irish"; language["60"] = "Italian"; language["61"] = "Japanese"; language["62"] = "Javanese"; language["63"] = "Kannada"; language["64"] = "Kashmiri"; language["65"] = "Kazakh"; language["66"] = "Kikuyu"; language["67"] = "Kinyarwanda"; language["68"] = "Kongo"; language["69"] = "Korean"; language["70"] = "Kurdish"; language["71"] = "Kyrgyz"; language["72"] = "Lao"; language["73"] = "Latin"; language["74"] = "Latvian"; language["75"] = "Lingala"; language["76"] = "Lithuanian"; language["77"] = "Luba-Katanga"; language["78"] = "Luxembourgish"; language["79"] = "Macedonian"; language["80"] = "Malagasy"; language["81"] = "Malay"; language["82"] = "Malayalam"; language["83"] = "Maltese"; language["84"] = "Marathi"; language["85"] = "Mongolian"; language["86"] = "Navajo"; language["87"] = "Ndebele, North"; language["88"] = "Ndebele, South"; language["89"] = "Ndonga"; language["90"] = "Nepali"; language["91"] = "Norwegian"; language["92"] = "Nuosu"; language["93"] = "Occitan"; language["94"] = "Oriya"; language["95"] = "Oromo"; language["96"] = "Ossetian"; language["97"] = "Panjabi"; language["98"] = "Pashto"; language["99"] = "Persian"; language["100"] = "Polish"; language["101"] = "Portuguese"; language["102"] = "Quechua"; language["103"] = "Romanian"; language["104"] = "Romansh"; language["105"] = "Rundi"; language["106"] = "Russian"; language["107"] = "Samoan"; language["108"] = "Sango"; language["109"] = "Sardinian"; language["151"] = "Scottish Gaelic"; language["110"] = "Serbian"; language["111"] = "Shona"; language["112"] = "Sindhi"; language["113"] = "Sinhalese"; language["114"] = "Slovak"; language["115"] = "Slovenian"; language["116"] = "Somali"; language["117"] = "Sotho, Southern"; language["118"] = "Spanish"; language["119"] = "Sundanese"; language["120"] = "Swahili"; language["121"] = "Swati"; language["122"] = "Swedish"; language["123"] = "Tagalog"; language["124"] = "Tahitian"; language["125"] = "Tajik"; language["126"] = "Tamil"; language["127"] = "Tatar"; language["128"] = "Telugu"; language["129"] = "Thai"; language["130"] = "Tibetan"; language["131"] = "Tigrinya"; language["132"] = "Tonga"; language["133"] = "Tsonga"; language["134"] = "Tswana"; language["135"] = "Turkish"; language["136"] = "Turkmen"; language["137"] = "Twi"; language["138"] = "Uighur"; language["139"] = "Ukrainian"; language["140"] = "Urdu"; language["141"] = "Uzbek"; language["142"] = "Venda"; language["143"] = "Vietnamese"; language["144"] = "Welsh"; language["145"] = "Wolof"; language["146"] = "Xhosa"; language["147"] = "Yiddish"; language["148"] = "Yoruba"; language["149"] = "Zhuang"; language["150"] = "Zulu"; } // Languages var status = []; { status["1"] = "Running"; status["2"] = "Ended"; status["3"] = "To Be Determined"; status["4"] = "In Development"; } // Status var show_type = []; { show_type["1"] = "Scripted"; show_type["2"] = "Animation"; show_type["3"] = "Reality"; show_type["4"] = "Talk Show"; show_type["5"] = "Documentary"; show_type["6"] = "Game Show"; show_type["7"] = "News"; show_type["8"] = "Sports"; show_type["9"] = "Variety"; show_type["10"] = "Award Show"; } // Show Type var current = []; var showID = new URLSearchParams(window.location.search).get("id"); $( document ).ready(function() { function refreshData() { var country = ""; var netPattern = /<(optgroup) label="([^"]+)">|<option value="(\d+)">([^<]+)<\/option>/g; var wcPattern = /<option value="(\d+)">([^<]+)<\/option>/g; var match = []; $.ajax( { "url": "/request/create", "method" : "get", "async": false, "success": function(data) { var start = data.indexOf('<select id="showrequest-network_id" name="ShowRequest[network_id]">'); var end = data.indexOf('<div class="form-group field-showrequest-officialsite">'); data = data.substring(start, end); var netEnd = data.indexOf('<div class="form-group field-showrequest-webchannel_id">'); var netData = data.substring(0, netEnd); // Will overwrite previous entries, in case it's been updated while ((match = netPattern.exec(netData)) !== null) { if (match[1] == "optgroup") country = match[2]; else networks[match[3]] = { "name": match[4], "country": country }; } GM_setValue("tvmaze_networks", networks); match = []; var wcEnd = data.indexOf('<div class="form-group field-showrequest-webchannel_id">', netEnd); var wcData = data.substring(netEnd, wcEnd); // We already have the data downloaded, so we might as well refresh both - even if only one was intended to be refreshed while ((match = wcPattern.exec(data)) !== null) { web_channels[match[1]] = match[2]; } GM_setValue("tvmaze_webchannels", web_channels); } }); } function addButtons(approve, reject) { if (approve) { addButton(true); } if (reject) { addButton(false); } } function addButton(isApprove) { var html = isApprove ? '<a class="success button round margin-right" href="/request/approve?id=' + showID + '">Approve</a>' : '<a class="alert button round" href="/request/reject?id=' + showID + '">Reject</a>' $("#buttons").append(html); } var forceReset = GM_getValue("tvmaze_forceReset", {}); if (forceReset !== 0) { refreshData(); GM_setValue("tvmaze_forceReset", 0); } var panelNum = $(".callout p").length; var checkNotes = false; if (panelNum > 3) { checkNotes = true; panelNum = 2; } else if ($(".callout p:eq(1)").text().trim().substring(8) == "New") // Don't continue if it's approved, but there's no notes { checkNotes = true; panelNum = 1; } if (checkNotes) { $(".callout p:gt(" + panelNum + ")").each(function(){ current.note = $(this).html(); if (current.note) { current.note = current.note.replace(/(https?:\/\/|www\.)[^ \n]+/g, function(link) { return "<a href='" + link + "' target='_blank'>" + link + "</a>"; }); $(this).html(current.note); } }); } current.name = $("td:first").text(); current.name = current.name.replace("'", "'"); $("td:first").html(current.name + " (<a href='/search?q=" + encodeURI(current.name) + "'>Search TVMaze</a>)"); current.network = $("td:eq(1)").text(); if (networks == {} || (current.network !== "(not set)" && !networks[current.network])) refreshData(); // If networks isn't null, then that means it was retrieved from the saved value // Fallbacks back to the original text are always used in case it wasn't set $("td:eq(1)").html((networks[current.network] ? "<a href='/networks/" + current.network + "/" + networks[current.network].name + "' target='_blank'>" + networks[current.network].name + "</a> (" + networks[current.network].country + ")" : current.network)); current.web = $("td:eq(2)").text(); if (web_channels == {} || (current.web !== "(not set)" && !web_channels[current.web])) refreshData(); // The web channels variable will only ever be empty if the refresh function failed (try again, maybe it timed out?) $("td:eq(2)").html((web_channels[current.web] ? "<a href='/webchannels/" + current.web + "/" + web_channels[current.web] + "' target='_blank'>" + web_channels[current.web] + "</a>" : current.web)); // The below information is not at all likely to be new, therefore no refresh will be done current.site = $("td:eq(3)").text(); $("td:eq(3)").html((current.site ? "<a href='" + current.site + "'>" + current.site + "</a>" : "")); current.status = $("td:eq(4)").text(); $("td:eq(4)").text(status[current.status] || current.status); current.type = $("td:eq(5)").text(); $("td:eq(5)").text(show_type[current.type] || current.type); current.lang = $("td:eq(6)").text(); $("td:eq(6)").text(language[current.lang] || current.lang); $("td:eq(9)").html($("td:eq(9)").text()); // Change the description text back to HTML current.thetvdb = $("td:eq(10)").text(); $("td:eq(10)").html((current.thetvdb !== "(not set)" ? "<a href='https://thetvdb.com/?tab=series&id=" + current.thetvdb + "' target='_blank'>" + current.thetvdb + "</a>" : current.thetvdb)); current.imdb = $("td:last").text(); $("td:last").html((current.imdb.length > 0 ? "<a href='http://www.imdb.com/title/" + current.imdb + "/' target='_blank'>" + current.imdb + "</a>" : current.imdb)); $("#w0").parent().append("<div id='buttons'></div"); var currentStatus = $(".callout p:eq(1)").text().replace("Status:", "").trim(); switch(currentStatus) { case "New": addButtons(true, true); break; case "Rejected": addButtons(true, false); break; case "Approved": // Skip break; } });