gazellegames ggn: create request with steamid , not working as of Greasemonkey 4.1

create request with steamid

La data de 16-12-2017. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name		gazellegames ggn: create request with steamid , not working as of Greasemonkey 4.1
// @namespace	 https://gazellegames.net/
// @version		 1.1
// @description	  create request with steamid
// @author		 hoannsi
// @match		 https://gazellegames.net/requests.php?action=new
// @require      https://code.jquery.com/jquery-3.1.1.min.js
// @grant		 GM_xmlhttpRequest
// ==/UserScript==

var steamBox = document.getElementById('artist_tr');
steamBox.innerHTML = steamBox.innerHTML + '<br> Steamid: <input id="steamId" size="45" value="" type="text">'

var platformm = document.getElementById('platform')
platformm.selectedIndex = 6;

function html2bb(str) {
    if(typeof str === "undefined") return "";

    str = str.replace(/\r/g, "");    
    str = str.replace(/\n/g, "");    
    str = str.replace(/< *br *\/*>/g, "\n");
    str = str.replace(/< *u *>/g, "[u]");
    str = str.replace(/< *h1*>/g, "[align=center][u]");
    str = str.replace(/< *\/h1*>/g, "[/u]\n\n[/align]");
    str = str.replace(/< *\/p*>/g, "");
    str = str.replace(/< *p*>/g, "");
    str = str.replace(/< *\/ *u *>/g, "[/u]");
    str = str.replace(/< *\/ *li *>/g, "");
    str = str.replace(/< *li *>/g, "[*]");
    str = str.replace(/< *\/ *ul *>/g, "");
    str = str.replace(/< *ul *class=\\*\"bb_ul\\*\" *>/g, "");
    str = str.replace(/< *h2 *class=\"bb_tag\" *>/g, "\n\n[u]");
    str = str.replace(/< *\/ *h2 *>/g, "[/u]");
    str = str.replace(/< *strong *>/g, "[b]");
    str = str.replace(/< *\/ *strong *>/g, "[/b]");
    str = str.replace(/< *i *>/g, "[i]");
    str = str.replace(/< *\/ *i *>/g, "[/i]");
    str = str.replace(/\&quot;/g, "\"");
    str = str.replace(/< *img *src="([^"]*)" *>/g, "");
    str = str.replace(/< *b *>/g, "[b]");
    str = str.replace(/< *\/ *b *>/g, "[/b]");
    str = str.replace(/< *a [^>]*>/g, "");
    str = str.replace(/< *\/ *a *>/g, "");
    //Yeah, all these damn stars. Because people put spaces where they shouldn't.
    return str;
}



(function() {
    'use strict';
 
        document.getElementById("steamId").addEventListener("blur", function() {			//After the "appid" input loses focus
            var request = new GM_xmlhttpRequest({method: "GET",								//We call the Steam API to get info on the game
                                                 url: "http://store.steampowered.com/api/appdetails?l=en&appids=" + document.getElementById("steamId").value,
                                                 responseType: "json",
                                                 onload: function(response) {

                                                     var gameInfo = response.response[document.getElementById("steamId").value].data;		//We store the data in gameInfo, since it's much easier to access this way
                                                     document.getElementsByName("title")[0].value = gameInfo.name;								//Get the name of the game
													
                                                     document.getElementsByName("description")[0].value = "http://store.steampowered.com/app/"+document.getElementById("steamId").value+"/\n\n[align=center][b][u]About the game[/u][/b][/align]\n" + html2bb(gameInfo.about_the_game); //Get the description, formatted appropriately
                                                     document.getElementsByName("year")[0].value = gameInfo.release_date.date.split(", ").pop(); //Get the year, which is actually the last number of "release_date.date"

                                                     //Genres are in an object array. Need to make them lowercase, replace spaces with dots and separate them with ", "
                                                     var genres = [];
                                                     gameInfo.genres.forEach(function (genre) {
                                                         var tag = genre.description.toLowerCase().replace(/ /g, "."); //Each genre is formatted as mentioned above and added to the "genres" array
                                                         switch (tag) {
                                                             case "rpg":
                                                                 tag = "role.playing.game";
                                                             default:
                                                                 genres.push(tag);
                                                             case "early.access":
                                                                 break;
                                                         }

                                                     });
                                                     document.getElementById("tags").value = genres.join(", ");							//Every string in the "genres" array is then concatenated with ", " between them

    var request2 = new XMLHttpRequest();
    request2.open( "GET", "https://gazellegames.net/imgup.php?img=" + gameInfo.header_image.split("?")[0], false ); // false for synchronous request
    request2.send( null );
    document.getElementsByName("image")[0].value = request2.responseText;													



                                                 }
                                                });
        });
    
})();