Skip to content

Instantly share code, notes, and snippets.

@rolandkakonyi
Last active March 29, 2016 09:18
Show Gist options
  • Save rolandkakonyi/12f444f6733e3d991499 to your computer and use it in GitHub Desktop.
Save rolandkakonyi/12f444f6733e3d991499 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name ESCImageToIMG
// @description A brief description of your script
// @author Roland.K
// @include http://*api.sports-cube.com/*
// @version 1.0
function decorate(){
var images = $('span.type-string').filter(function( index ) {
return $($(this).siblings("span.property")[0]).text() == "self" && /\/images\/?/i.test($(this).text())
}).parent().parent().parent()
images.find("span.property").filter(function(){
return $(this).text() == "src" }).parent().find("span.type-string").each(function(){
var base64value = $(this).text().split('"')[1]
$(this).html('<img src="data:image/png;base64,'+base64value+'" alt="img"/>')
})
var urls = $('span.type-string').filter(function( index ) {
return /\/v(.*)\/?/i.test($(this).text())
}).each(function(){
var url = $(this).text().split('"')[1]
$(this).html('<a href="'+url+'">'+url+'</a>')
})
}
function renderImages(){
$("span.type-string:contains('/images/')").each(function(e){
var item = $(this);
$.getJSON($(this).text(),function(response, status, xhr){
item.html(item.html() + '<br/><img src="data:image/png;base64,'+response.data.src+'" alt="img"/>');
});
});
}
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
var interval = setInterval(timedDecorate, 200);
function timedDecorate() {
console.log("try to load")
if(typeof($) == "function"){
console.log("succeed to load")
decorate();
renderImages();
window.clearInterval(interval);
}
}
// ==/UserScript==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment