")
$("#quotePlace").append("
");
//Apply css to the quote and quote author
$("#quotePlace").css({"padding-top": "15%",
"padding-left": "25%",
"padding-right": "25%",
"font-size": "240%",
"color": "#f00",
"-webkit-filter": "invert(50%)",
"filter": "invert(50%)"});
//Take the quote and quote author and put them in there paragraphs
var apiArray = new Array();
GM.xmlHttpRequest({
method: "GET",
url: "https://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=xml&lang=en",
responseType: "xml",
onload: function(data) {
apiArray = getXMLToArray(data.responseText);
console.log(apiArray.QUOTE.QUOTETEXT[0]);
console.log(apiArray.QUOTE.QUOTEAUTHOR[0]);
$("#quote").html('"' + apiArray.QUOTE.QUOTETEXT[0] + '"');
$("#author").html('-' + apiArray.QUOTE.QUOTEAUTHOR[0]);
}
});
}
function getXMLToArray(xmlDoc){
var thisArray = new Array();
//Check XML doc
if($(xmlDoc).children().length > 0){
//Foreach Node found
$(xmlDoc).children().each(function(){
if($(xmlDoc).find(this.nodeName).children().length > 0){
//If it has children recursively get the inner array
var NextNode = $(xmlDoc).find(this.nodeName);
thisArray[this.nodeName] = getXMLToArray(NextNode);
} else {
//If not then store the next value to the current array
thisArray[this.nodeName] = [];
$(xmlDoc).children(this.nodeName).each(function(){
thisArray[this.nodeName].push($(this).text());
});
}
});
}
return thisArray;
}