1
2 // ==UserScript==
3 // @name BlockFlash-Revisited
4 // @namespace http://snippets.dzone.com/posts/show/3054
5 // @description Do not start Flash animation until you click on them.
6 // @include *
7 // @exclude http://www.macromedia.com/*
8 // @exclude http://www.atomfilms.com/*
9 // @exclude http://uploads.ungrounded.net/*
10 // @exclude http://www.albinoblacksheep.com/*
11 // ==/UserScript==
12
13 /*
14 Revised by Andrew Pennebaker (andrew.pennebaker@gmail.com)
15
16 Author: Jos van den Oever (jos@vandenoever.info)
17
18 License: GPL
19
20 Version history:
21 2006-02-12: initial version
22 2006-11-28: changed appearance
23
24 Inspiration for this script comes from the removeFlash script and the FlashBlock firefox extension.
25 */
26
27 (function () {
28 var objects=document.getElementsByTagName("object");
29
30 for (i=0; i<objects.length; i++) {
31 var flash=objects[i];
32
33 if (flash.innerHTML.match(/.swf|shockwave|flash/)) {
34 var placeholder=document.createElement("div");
35
36 placeholder.style.cursor='pointer';
37 placeholder.style.background='orange'; // 'gray '
38 placeholder.style.textAlign='center';
39 placeholder.style.color='black';
40 placeholder.innerHTML="[Play Flash]";
41
42 flash.parentNode.insertBefore(placeholder, flash);
43 flash.on=false;
44
45 placeholder.addEventListener(
46 'click',
47 function() {
48 if (flash.on) {
49 flash.style.display='none';
50 placeholder.innerHTML="[Play Flash]";
51 flash.on=false;
52 }
53 else {
54 flash.style.display='';
55 placeholder.innerHTML="[Stop Flash]";
56 flash.on=true;
57 }
58 },
59 true
60 );
61
62 flash.style.display='none';
63 }
64 }
65 })();