Skip to content

Commit

Permalink
Facebook
Browse files Browse the repository at this point in the history
Update Facebook button download
  • Loading branch information
Leonardo committed Dec 18, 2016
1 parent 1c5ab15 commit d36a8a1
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 113 deletions.
2 changes: 1 addition & 1 deletion Extension/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 !"
Expand Down
2 changes: 1 addition & 1 deletion Extension/_locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 !"
Expand Down
3 changes: 2 additions & 1 deletion Extension/buttons/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
139 changes: 106 additions & 33 deletions Extension/buttons/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..." );

Expand All @@ -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 ){}

Expand All @@ -80,7 +153,7 @@

//console.log( "[ GAM ] SetUp to observe ..." );

var toobserv = document.body;
var toobserv = document.getElementById( targetid );

if( !toobserv )return false;

Expand Down
14 changes: 2 additions & 12 deletions Extension/libs/jquery.gam.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<e.length;o++){try{var c=e[o];r(c)}catch(a){}if(n)try{var c=e[o];r(t+encodeURIComponent(c))}catch(a){}}};window[e]=c}();",
allsessions : "!function(e){if(!e)return!1;for(var o=[],t=function(e){return e=e.replace(/(\\\\)/g,''),e.match(/(http?s?:?\\\\?\\/?\\\\?\\/[^\\s,\\\"\\'<>]+)/g)||[]},n=document.querySelectorAll('video, audio, embed, source, object, param')||[],r=0;r<n.length;r++)try{for(var c=n[r].attributes||[],a=0;a<c.length;a++)try{var i=t(decodeURIComponent(c[a].value.trim()));i&&(o=o.concat(i))}catch(l){}}catch(l){}e(o,!1)}(window.gammodule);",
buttonbuilder : "!function(){window.gambuttonbuilder=function(t,e,A,r){if(!t||!e)return!1;var a=function(t,e,A){if(!t)return null;e=e||'" + chrome.i18n.getMessage( "m20" ) + "';var r=document.createElement('div'),a=document.createElement('img'),i=document.createElement('a');return i.setAttribute('href',t),A?i.setAttribute('target','_blank'):'#'!=t&&(i.setAttribute('download','GrabAnyMedia.mp4'),i.setAttribute('target','_blank')),i.setAttribute('style',['text-decoration:none!important','font-size:11px!important','font-family:monospace!important'].join(';')),i.textContent=e,a.setAttribute('draggable','false'),a.setAttribute('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAf9JREFUOI2Nj81LVGEUxn/vuTNz647TF7WJmGEsq0WLGomCssXQwlq0qrZhkQaCBNO/EUKS6WyidR+bFmlk9CEkmSkFfWA6ChmVSYTOjFfufd8WjtPM3Ck6q/c9z/P8zjmKmkr1TaaUMR1KmTRaEgBG9IxCHivRfaPteyYq/Wrt0dw/5xhT6BE4XwutLGNMNlxYd3kkEy+WAc39c47y84OIOvqvcBmieRYu2q0jmXhRVqmFnv8Jr62rhGNe1O0GUKm+yZTA2N9CG2wh3djAyaYYjZsjHL+V+wMUfSCkjOlAqaqQHVK0JKK07opxJO4QklX9ww+3+hRf2kNK6TRYpdt8rhzexKl923DCEthmYHKx6q8VacG3EgBe/hf5Ty/Zbq/UDRvg4dRSVU80ScEYlr/lyOfG8V2XizcGuXB9gBe5n1Xm11+KzOe9AFgWZ0a/ut9nV0cAxsDz9585d/Uuw1MLZeODmvVLNS14/kg9BaD73jAArmd4NL0U0I0yQyEj1jXgTD3A29l57r+aYsHaQn5FB3StrawCaOq6eRvfO10PIvZ6YrsPBadD79ilpk4BCHvRNq1kIuBS4OzYWwernzTYoQyAALzrPbtk61gLVuROpc3eGsdyNgYmR+3IiadtyeXSjOo6mP243/jSrhVp0SRL7WmjzJDWVna8c+ebSv9vmWG756vCwY8AAAAASUVORK5CYII='),a.setAttribute('style',['vertical-align:middle!important','margin-right: 5px!important'].join(';')),a.classList.add('img'),r.setAttribute('style','margin:15px!important'),r.appendChild(a),r.appendChild(i),r},i=a(t,A,r);return i?(e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i),!0):!1}}();",
buttonbuilder : "!function(){window.gambuttonbuilder=function(t,e,A,r){if(!t||!e)return!1;var a=function(t,e,A){if(!t)return null;e=e||'" + chrome.i18n.getMessage( "m20" ) + "';var r=document.createElement('div'),a=document.createElement('img'),i=document.createElement('a');return i.setAttribute('href',t),A?i.setAttribute('target','_blank'):'#'!=t&&(i.setAttribute('download','GrabAnyMedia.mp4'),i.setAttribute('target','_blank')),i.setAttribute('style',['text-decoration:none!important','font-size:11px!important','font-family:monospace!important','color:rgb(224, 157, 31)!important'].join(';')),i.textContent=e,a.setAttribute('draggable','false'),a.setAttribute('src','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAf9JREFUOI2Nj81LVGEUxn/vuTNz647TF7WJmGEsq0WLGomCssXQwlq0qrZhkQaCBNO/EUKS6WyidR+bFmlk9CEkmSkFfWA6ChmVSYTOjFfufd8WjtPM3Ck6q/c9z/P8zjmKmkr1TaaUMR1KmTRaEgBG9IxCHivRfaPteyYq/Wrt0dw/5xhT6BE4XwutLGNMNlxYd3kkEy+WAc39c47y84OIOvqvcBmieRYu2q0jmXhRVqmFnv8Jr62rhGNe1O0GUKm+yZTA2N9CG2wh3djAyaYYjZsjHL+V+wMUfSCkjOlAqaqQHVK0JKK07opxJO4QklX9ww+3+hRf2kNK6TRYpdt8rhzexKl923DCEthmYHKx6q8VacG3EgBe/hf5Ty/Zbq/UDRvg4dRSVU80ScEYlr/lyOfG8V2XizcGuXB9gBe5n1Xm11+KzOe9AFgWZ0a/ut9nV0cAxsDz9585d/Uuw1MLZeODmvVLNS14/kg9BaD73jAArmd4NL0U0I0yQyEj1jXgTD3A29l57r+aYsHaQn5FB3StrawCaOq6eRvfO10PIvZ6YrsPBadD79ilpk4BCHvRNq1kIuBS4OzYWwernzTYoQyAALzrPbtk61gLVuROpc3eGsdyNgYmR+3IiadtyeXSjOo6mP243/jSrhVp0SRL7WmjzJDWVna8c+ebSv9vmWG756vCwY8AAAAASUVORK5CYII='),a.setAttribute('style',['vertical-align:middle!important','margin-right: 5px!important'].join(';')),a.classList.add('img'),r.setAttribute('style','margin:15px!important'),r.appendChild(a),r.appendChild(i),r},i=a(t,A,r);return i?(e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i),!0):!1}}();",
modules : {

"youtube" : {
Expand All @@ -351,16 +351,6 @@

,

"facebook" : {

enabled : true,
file : "modules/facebook.js",
code : "!function(a){if(!a)return!1;var b=function(){var a=[];for(var b in window)if(b.match(/^(swf)/gi)){try{var c=JSON.parse(decodeURIComponent(window[b].variables.params));a.push(c.video_data.progressive.hd_src)}catch(a){}try{var c=JSON.parse(decodeURIComponent(window[b].variables.params));a.push(c.video_data.progressive.sd_src)}catch(a){}}return a};a(b(),!1)}(window.gammodule);"

}

,

"dailymotion" : { // Ho dovuto aggiungere un '\' in più replace(/\\\/g,'')

enabled : true,
Expand Down Expand Up @@ -395,7 +385,7 @@
"facebook" : {

enabled : true,
code : "!function(){var t='gambutton',e='.mtm',a='.uiLayer',r=function(){if(!window.gambuttonbuilder)return!1;for(var r=document.querySelectorAll(\"[data-swfid^='swf_id_']:not(.\"+t+')')||[],o=0;o<r.length;o++)try{var n=r[o].getAttribute('data-swfid'),i=JSON.parse(decodeURIComponent(window[n].variables.params)),c='';try{c=i.video_data.progressive.hd_src}catch(d){}try{c&&''!=c||(c=i.video_data.progressive.sd_src)}catch(d){}if(!c||''==c)continue;var s=r[o].closest(e)||r[o].closest(a).querySelector('#fbPhotoChannelChannelFeedback');window.gambuttonbuilder(c,s)&&r[o].classList.add(t)}catch(d){}},o=document.body;if(!o)return!1;var n=new MutationObserver(function(t){t.forEach(function(){r()})}),i={attributes:!0,childList:!0,characterData:!0};n.observe(o,i),r()}();"
code : "!function(){var t='gambutton',e='globalContainer',n=new RegExp('/videos/','gi'),r=new RegExp('(\"sd_src\":\")[^\"]+(?=\")','g'),c=new RegExp('(\"sd_src\":\")','g'),a=new RegExp('(sd_src:\")[^\"]+(?=\")','g'),u=new RegExp('(sd_src:\")','g'),i=function(){try{return new XMLHttpRequest}catch(t){}try{return new ActiveXObject('Msxml3.XMLHTTP')}catch(t){}try{return new ActiveXObject('Msxml2.XMLHTTP.6.0')}catch(t){}try{return new ActiveXObject('Msxml2.XMLHTTP.3.0')}catch(t){}try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(t){}try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(t){}return null},o=function(t,e){if(!t||!e)return!1;var n=i();n.open('GET',t,!0),n.onload=function(){if(n.readyState===n.DONE&&200===n.status){var i=n.responseText.match(r);if(i||t!=location.href||(i=document.getElementsByTagName('html')[0].textContent.match(a)),i){var o=i[i.length-1].replace(c,'').replace(u,'').replace(/\\\\/g,'');window.gambuttonbuilder(o,e)}}},n.send(null)},l=function(){if(!window.gambuttonbuilder)return!1;for(var e=document.querySelectorAll('input[type=\"text\"]:not(.'+t+')')||[],r=0;r<e.length;r++)try{var c=e[r].getAttribute('value')||'';if(e[r].classList.add(t),!c.match(n))continue;o(c,e[r].parentNode)}catch(a){}},s=document.getElementById(e);if(!s)return!1;var g=new MutationObserver(function(t){t.forEach(function(){l()})}),d={attributes:!0,childList:!0,characterData:!0};g.observe(s,d),l()}();"

}

Expand Down
2 changes: 1 addition & 1 deletion Extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"manifest_version" : 2,
"author" : "Leonardo Ciaccio",
"version" : "6.0.1.2",
"version" : "6.0.1.3",
"name" : "Grab Any Media",
"default_locale" : "en",
"description" : "__MSG_des__",
Expand Down
63 changes: 0 additions & 63 deletions Extension/modules/facebook.js

This file was deleted.

2 changes: 1 addition & 1 deletion Extension/modules/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
fakedomain = "//localhost/?",
pingout = 2000;

// ( it ) --> Potreemo essere su browser sconosciuti
// ( it ) --> Potremmo essere su browser sconosciuti

var getXHR = function(){

Expand Down

0 comments on commit d36a8a1

Please sign in to comment.