@@ -373,9 +373,9 @@ var gfyObject = function (gfyElem, gfyIndex) {
373
373
gfyRootElem . parentNode . replaceChild ( newElem , gfyRootElem ) ;
374
374
gfyRootElem = newElem ;
375
375
// call gfycat API to get info for this gfycat
376
- loadJSONP ( "https://gfycat.com/cajax/get /" + gfyId , function ( data ) {
377
- if ( data ) {
378
- gfyItem = data . gfyItem ;
376
+ loadJSON ( "https://api. gfycat.com/v1/gfycats /" + gfyId , function ( dataGfyData ) {
377
+ if ( dataGfyData ) {
378
+ gfyItem = JSON . parse ( dataGfyData ) . gfyItem ;
379
379
gfyMp4Url = gfyItem . mp4Url ;
380
380
gfyWebmUrl = gfyItem . webmUrl ;
381
381
gfyFrameRate = gfyItem . frameRate ;
@@ -416,30 +416,17 @@ var gfyObject = function (gfyElem, gfyIndex) {
416
416
417
417
// used to load ajax info for each gfycat on the page
418
418
// callback functions must be setup and uniquely named for each
419
- function loadJSONP ( url , callback , context ) {
420
- var unique = Math . floor ( ( Math . random ( ) * 10000000 ) + 1 ) ;
421
- // INIT
422
- var name = "_" + gfyId + "_" + unique ++ ;
423
- if ( url . match ( / \? / ) ) url += "&callback=" + name ;
424
- else url += "?callback=" + name ;
425
-
426
- // Create script
427
- var script = document . createElement ( 'script' ) ;
428
- script . type = 'text/javascript' ;
429
- script . src = url ;
430
-
431
- // Setup handler
432
- window [ name ] = function ( data ) {
433
- callback . call ( ( context || window ) , data ) ;
434
- document . getElementsByTagName ( 'head' ) [ 0 ] . removeChild ( script ) ;
435
- script = null ;
436
- try {
437
- delete window [ name ] ;
438
- } catch ( e ) { }
419
+ function loadJSON ( url , callback , context ) {
420
+ var xobj = new XMLHttpRequest ( ) ;
421
+ xobj . overrideMimeType ( "application/json" ) ;
422
+ xobj . open ( 'GET' , url , true ) ; // Replace 'my_data' with the path to your file
423
+ xobj . onreadystatechange = function ( ) {
424
+ if ( xobj . readyState == 4 && xobj . status == "200" ) {
425
+ // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
426
+ callback ( xobj . responseText ) ;
427
+ }
439
428
} ;
440
-
441
- // Load JSON
442
- document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( script ) ;
429
+ xobj . send ( null ) ;
443
430
}
444
431
445
432
function setSize ( ) {
0 commit comments