12
PORTING FLASHBLOCK TO JETPACK PLATFORM DRAFT

Porting Flashblock to Jetpack Platform (draft)

Embed Size (px)

DESCRIPTION

How I started to port Flashblock to Jetpack. It still needs some performance improvements and polish but it's a good start. Jetpack is promising platform.

Citation preview

Page 1: Porting Flashblock to Jetpack Platform (draft)

PORTING FLASHBLOCKTO JETPACK PLATFORM

DRAFT

Page 2: Porting Flashblock to Jetpack Platform (draft)

WHAT’S FLASHBLOCK?

• Flashblock is an extension for the Firefox that blocks ALL Flash content from loading. It then leaves placeholders on the webpage that allow you to click to download and then view the Flash content.

Page 3: Porting Flashblock to Jetpack Platform (draft)

WHAT’S JETPACK?

• Jetpack is an API for allowing you to write Firefox add-ons using the web technologies you already know (e.g. HTML, CSS and Javascript).

• Almost one-clic install and without restart

Page 4: Porting Flashblock to Jetpack Platform (draft)

WHAT’S THE PLAN?

• The basic algorithm

• Some code

• What could be improved

• Conclusion

Page 5: Porting Flashblock to Jetpack Platform (draft)

ALGORITHM

Quite simple :

• Look for all Flash object

• Replace them by a placeholder

• A click on a placeholder put the Flash object back

Page 6: Porting Flashblock to Jetpack Platform (draft)

ON/OFF BUTTON ON THE STATUS BAR

jetpack.statusBar.append({

html: 'Flashblok?<input type="checkbox">',

width: 76,

onReady: function(widget){

$("input", widget).click(function(){

if( this.checked ){

jetpack.tabs.onReady( removeEmbeds );

removeEmbeds(jetpack.tabs.focused.contentDocument);

}

else jetpack.tabs.onReady.unbind( removeEmbeds );

});

}

});

Page 7: Porting Flashblock to Jetpack Platform (draft)

FIND FLASH OBJECTS

Lazzy method

function findFlash(doc){

return $(doc).find('object, embed');

}

Better method

Search for :

• object[codebase*="swflash.cab"]

• object[data*=".swf"]

• embed[type="application/x-shockwave-flash"]

• etc.

Page 8: Porting Flashblock to Jetpack Platform (draft)

REMOVE FLASH

function removeEmbeds(doc){

findFlash(doc).each(function() {

var placeHolder = createPlaceHolder(...);

// Here I put code to remember my removed Flash object

placeHolder.click(function(eventObject){

$(this).replaceWith(myDeletedEmbed);

});

$(this).replaceWith(placeHolder); // So easy with jQuery

});

}

Page 9: Porting Flashblock to Jetpack Platform (draft)

PLACEHOLDERS

• Full CSS3

• Make use of text-shadow, -moz-box-shadow, -moz-border-radius and -moz-linear-gradient (coming with Firefox 3.6)

Page 10: Porting Flashblock to Jetpack Platform (draft)

NEXT STEPS

• Block Flash objects sooner

• Improve memory footprint

• Better way to remember removed objects

• Block Silverlight, Authorware, Director, etc. objects

• Use simple storage JEP to remember block status

• Use the coming menu JEP and simple storage one to provide whitelist management

Page 11: Porting Flashblock to Jetpack Platform (draft)

CONCLUSION

• It’s very easy to develop an extension

• Still lacks some features like localisation