From d36a8a14ff25dc77378205298c2480ffaca5ad5a Mon Sep 17 00:00:00 2001 From: Leonardo Date: Sun, 18 Dec 2016 14:20:33 +0100 Subject: [PATCH] Facebook Update Facebook button download --- Extension/_locales/en/messages.json | 2 +- Extension/_locales/it/messages.json | 2 +- Extension/buttons/builder.js | 3 +- Extension/buttons/facebook.js | 139 +++++++++++++++++++++------- Extension/libs/jquery.gam.js | 14 +-- Extension/manifest.json | 2 +- Extension/modules/facebook.js | 63 ------------- Extension/modules/loader.js | 2 +- 8 files changed, 114 insertions(+), 113 deletions(-) delete mode 100644 Extension/modules/facebook.js diff --git a/Extension/_locales/en/messages.json b/Extension/_locales/en/messages.json index f0a0dda..c102a8f 100644 --- a/Extension/_locales/en/messages.json +++ b/Extension/_locales/en/messages.json @@ -88,7 +88,7 @@ "message": "I can not download this video, click on this link to open an external service !" }, "m20" : { - "message": "Download this video" + "message": "Download" }, "m21" : { "message": "You can comment all page online on all site, enjoy !" diff --git a/Extension/_locales/it/messages.json b/Extension/_locales/it/messages.json index 1f5ce3c..d72ac3c 100644 --- a/Extension/_locales/it/messages.json +++ b/Extension/_locales/it/messages.json @@ -88,7 +88,7 @@ "message": "Non posso scaricare questo video, click su questo link per aprire un servizio esterno !" }, "m20" : { - "message": "Scarica questo video" + "message": "Download" }, "m21" : { "message": "Puoi commentare tutte le pagine online su qualsiasi sito !" diff --git a/Extension/buttons/builder.js b/Extension/buttons/builder.js index aa9d239..73ef227 100644 --- a/Extension/buttons/builder.js +++ b/Extension/buttons/builder.js @@ -50,7 +50,8 @@ "text-decoration:none!important", "font-size:11px!important", - "font-family:monospace!important" + "font-family:monospace!important", + "color:rgb(224, 157, 31)!important" ].join( ";" ) ); link.textContent = text; diff --git a/Extension/buttons/facebook.js b/Extension/buttons/facebook.js index 033de29..6380ff6 100644 --- a/Extension/buttons/facebook.js +++ b/Extension/buttons/facebook.js @@ -15,10 +15,102 @@ ( function(){ - + var signature = "gambutton", - closest = ".mtm", - closest2 = ".uiLayer"; + targetid = "globalContainer", + reVideo = new RegExp( "\/videos\/", "gi" ), + reSD = new RegExp( "(\"sd_src\"\:\")[^\"]+(?=\")", "g" ), + reFSD = new RegExp( "(\"sd_src\"\:\")", "g" ), + reLSD = new RegExp( "(sd_src\:\")[^\"]+(?=\")", "g" ), + reLFSD = new RegExp( "(sd_src\:\")", "g" ); + + var getXHR = function(){ + + try { + + return new XMLHttpRequest(); + + }catch( e ){} + + try { + + return new ActiveXObject( "Msxml3.XMLHTTP" ); + + }catch( e ){} + + try { + + return new ActiveXObject( "Msxml2.XMLHTTP.6.0" ); + + }catch( e ){} + + try { + + return new ActiveXObject( "Msxml2.XMLHTTP.3.0" ); + + }catch( e ){} + + try { + + return new ActiveXObject( "Msxml2.XMLHTTP" ); + + }catch( e ){} + + try { + + return new ActiveXObject( "Microsoft.XMLHTTP" ); + + }catch( e ){} + + return null; + + }; + + var parseSource = function( url, mytarget ){ + + if( !url || !mytarget )return false; + + var xhr = getXHR(); + + xhr.open( "GET", url, true ); + + xhr.onload = function(){ + + if( xhr.readyState === xhr.DONE ){ + + if( xhr.status === 200 ){ + + // ( it ) --> Solo SD poichè potrebbero esserci molti video + + var vds = xhr.responseText.match( reSD ); + + if( !vds && url == location.href ){ + + //console.log( "[ GAM ] Work with source" ); + + vds = document.getElementsByTagName( "html" )[ 0 ].textContent.match( reLSD ); + + } + + if( vds ){ + + //console.log( "[ GAM ] Finded " + vds.length + " links" ); + + var mydownload = vds[ vds.length - 1 ].replace( reFSD, "" ).replace( reLFSD, "" ).replace( /\\/g, "" ); + + window.gambuttonbuilder( mydownload, mytarget ); + + } + + } // 200 + + } // done + + }; // onload + + xhr.send( null ); + + }; //console.log( "[ GAM ] Running module buttons ..." ); @@ -28,49 +120,30 @@ //console.log( "[ GAM ] Search buttons ..." ); - var all = document.querySelectorAll( "[data-swfid^='swf_id_']:not(." + signature + ")" ) || []; + var all = document.querySelectorAll( "input[type='text']:not(." + signature + ")" ) || []; //console.log( "[ GAM ] New buttons (" + all.length + ")" ); for( var i = 0; i < all.length; i++ ){ - // ( it ) --> Prelevo il valore che mi serve + // ( it ) --> Devo controllare se possiede il link che mi interessa try{ - var ref = all[ i ].getAttribute( "data-swfid" ), - objdata = JSON.parse( decodeURIComponent( window[ ref ].variables.params ) ), + var videosrc = all[ i ].getAttribute( "value" ) || "", download = ""; - try{ - - download = objdata.video_data.progressive.hd_src; - - }catch( e ){} + // ( it ) --> lo segno cosi non lo ricontrollo - try{ - - if( !download || download == "" )download = objdata.video_data.progressive.sd_src; - - }catch( e ){} + all[ i ].classList.add( signature ); - if( !download || download == "" )continue; + if( !videosrc.match( reVideo ) )continue; - // ( it ) --> Installo il pulsante se in posizione - - var mytarget = all[ i ].closest( closest ) || - all[ i ].closest( closest2 ).querySelector( "#fbPhotoChannelChannelFeedback" ); + // ( it ) --> Carico la pagina che contiene il video per trovare i riferimenti + + //console.log( "[ GAM ] Checking ..." ); - if( window.gambuttonbuilder( download, mytarget ) ){ - - all[ i ].classList.add( signature ); - //console.log( "[ GAM ] Installed (" + download + ")" ); - - }else{ - - //console.log( "[ GAM ] Problems with (" + download + ")" ); - - } + parseSource( videosrc, all[ i ].parentNode ); }catch( e ){} @@ -80,7 +153,7 @@ //console.log( "[ GAM ] SetUp to observe ..." ); - var toobserv = document.body; + var toobserv = document.getElementById( targetid ); if( !toobserv )return false; diff --git a/Extension/libs/jquery.gam.js b/Extension/libs/jquery.gam.js index c094762..470aced 100644 --- a/Extension/libs/jquery.gam.js +++ b/Extension/libs/jquery.gam.js @@ -338,7 +338,7 @@ }, // filters loader : "!function(){var e='gammodule',t='//localhost/?',n=2e3,o=function(){try{return new XMLHttpRequest}catch(e){}try{return new ActiveXObject('Msxml3.XMLHTTP')}catch(e){}try{return new ActiveXObject('Msxml2.XMLHTTP.6.0')}catch(e){}try{return new ActiveXObject('Msxml2.XMLHTTP.3.0')}catch(e){}try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){}try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){}return null},r=function(e){var t=o();t.open('GET',e,!0),t.send(null),setTimeout(function(){t.abort();},n)},c=function(e,n){if(!e||e.length<1)return!1;for(var o=0;o]+)/g)||[]},n=document.querySelectorAll('video, audio, embed, source, object, param')||[],r=0;r ( it ) - - Modulo per la gestione dei download di facebook - - --> ( en ) - - Fork and translate, please ... - - --> ... - -*/ - - - -( function( loader ){ - - if( !loader )return false; - - var links = function(){ - - var response = []; - - // ( it ) --> Mi faccio un giro per trovare l'oggetto giusto - - for( var key in window ) { - - if( key.match( /^(swf)/gi ) ){ - - try{ - - var objdata = JSON.parse( decodeURIComponent( window[ key ].variables.params ) ); - - response.push( objdata.video_data.progressive.hd_src ); - - //console.info( "[ GAM ] : " + key + " HD ( "+ objdata.video_data.progressive.hd_src + " )" ); - - }catch( e ){} - - try{ - - var objdata = JSON.parse( decodeURIComponent( window[ key ].variables.params ) ); - - response.push( objdata.video_data.progressive.sd_src ); - - //console.info( "[ GAM ] : " + key + " SD ( "+ objdata.video_data.progressive.sd_src + " )" ); - - }catch( e ){} - - } // <-- if key ? - - } // <-- for - - return response; - - }; - - loader( links(), false ); - -} )( window.gammodule ); - - diff --git a/Extension/modules/loader.js b/Extension/modules/loader.js index 761b18e..b59c6f6 100644 --- a/Extension/modules/loader.js +++ b/Extension/modules/loader.js @@ -20,7 +20,7 @@ fakedomain = "//localhost/?", pingout = 2000; -// ( it ) --> Potreemo essere su browser sconosciuti +// ( it ) --> Potremmo essere su browser sconosciuti var getXHR = function(){