4
xmlns="http://www.mozilla.org/xbl"
5
xmlns:html="http://www.w3.org/1999/xhtml"
13
//From Jesse's XPCNativeWrapper: http://mavra.perilith.com/~luser/content/native.js
14
function nativeMethod(untrustedObject, methodName)
16
// happier stack traces and faster multiple calls
17
var fun = Components.lookupMethod(untrustedObject, methodName);
21
return fun.apply(untrustedObject, arguments);
25
function flashblockCreatePlaceholder(isStandalone) {
27
var flashblockCreateElement = nativeMethod(document, "createElementNS");
28
var placeholder = flashblockCreateElement("http://www.w3.org/1999/xhtml", "div");
29
placeholder.isStandalone = isStandalone;
33
// Substitute the animation with a placeholder
34
function flashblockShowPlaceholder() {
35
// Just in case the object has been moved away from under our feet during
36
// the timeout, re-assign the parent node. See bug 13680
37
// parent = current.parentNode;
38
var newParent = current.parentNode;
39
parent = newParent ? newParent : parent;
40
parent.insertBefore(placeholder, current);
41
if(placeholder.isStandalone) {
42
placeholder.flashblock = "frame";
43
if ("StopPlay" in current)
45
if ("LoadMovie" in current)
46
current.LoadMovie(0, "");
47
current.prevWidth = current.width;
48
current.prevHeight = current.height;
49
current.width = current.height = 0;
51
placeholder.flashblock = "normal";
52
parent.removeChild(current);
56
// Show the original animation
57
function flashblockShowFlash(event) {
58
if( event.type == "keypress" && event.keyCode != KeyEvent.DOM_VK_RETURN)
60
event.stopPropagation();
61
if(placeholder.flashblock == "frame") {
62
current.height = current.prevHeight;
63
current.width = current.prevWidth;
64
current.src = placeholder.title;
65
if ("LoadMovie" in current)
66
current.LoadMovie(0, current.src);
68
parent.insertBefore(current, placeholder);
69
if (placeholder.hasAttribute("srcAttribute")) {
70
current.setAttribute("src", placeholder.getAttribute("srcAttribute"));
72
if (placeholder.hasAttribute("movieAttribute")) {
73
current.setAttribute("movie", placeholder.getAttribute("movieAttribute"));
75
if (placeholder.hasAttribute("dataAttribute")) {
76
current.setAttribute("data", placeholder.getAttribute("dataAttribute"));
78
if (placeholder.movieParam) {
79
var mparam = placeholder.movieParam;
80
mparam[0].value = mparam[1];
82
if (placeholder.hasAttribute("embedsrc")) {
83
var embeds = current.getElementsByTagName("embed");
84
if (embeds && embeds.length > 0) {
85
embeds[0].setAttribute("src", placeholder.getAttribute("embedsrc"));
89
parent.removeChild(placeholder);
92
function flashblockIsWhitelisted() {
93
// Check if the page that loaded the Flash site is whitelisted
94
// Thanks to Neil on #mozilla for suggesting this method, I would never have
95
// thought of it on my own. :-)
96
// Lor 20041215: Use "UIEvents" to make it work in post-1.0 FF
97
// (thanks to Neil again)
98
var flashblockEvent = document.createEvent("UIEvents");
100
if(flashblockEvent) {
101
flashblockEvent.initEvent("flashblockCheckLoad", true, true);
102
document.dispatchEvent(flashblockEvent);
103
if(flashblockEvent.getPreventDefault() == true) {
111
function flashblockSetImage(placeholder, type) {
112
var inactiveurl = "url(chrome://flashblock/content/" + type + ".png) no-repeat center";
113
var activeurl = "url(chrome://flashblock/content/flashplay.png) no-repeat center";
114
placeholder.setAttribute("bgInactive", inactiveurl);
115
placeholder.setAttribute("bgActive", activeurl);
116
placeholder.style.background = inactiveurl;
119
function flashblockStylePlaceholder(flash, placeholder, isStandalone) {
120
// If object's size was relative, use that.
121
// Otherwise, set size to minimum 32x32 px
122
placeholder.style.setProperty("min-width", "32px", "important");
123
placeholder.style.setProperty("min-height", "32px", "important");
124
// The size and positioning may come from a class
125
var fClass = flash.getAttribute("class");
127
placeholder.setAttribute("class", fClass);
129
var fStyle = window.getComputedStyle(flash, "");
131
var fWidth = fStyle.getPropertyValue("width");
132
var width = parseInt(flash.width || flash.style.width);
133
if (fWidth && parseInt(fWidth) > 32)
135
else if(flash.width.match("%$"))
138
width = Math.max(width,32) + "px";
141
placeholder.style.width = width;
143
var fHeight = fStyle.getPropertyValue("height");
144
var height = parseInt(flash.height || flash.style.height);
145
if (fHeight && parseInt(fHeight) > 32)
147
else if(flash.height.match("%$"))
148
height = flash.height;
150
height = Math.max(height,32) + "px";
153
placeholder.style.height = height;
155
// Add styling rules to placeholder div.
156
placeholder.style.border = "1px solid #dfdfdf";
157
placeholder.style.cursor = "pointer";
158
placeholder.style.overflow = "hidden";
159
var disp = fStyle.getPropertyValue("display");
160
placeholder.style.display = disp == "block" ? "block" : "inline-block";
161
placeholder.style.setProperty("visibility", "visible", "important");
163
// The size of the placeholder should include borders too,
164
// otherwise scrollbars appear for blocked standalone objects
165
placeholder.style.MozBoxSizing = "border-box";
167
// Make some style adjustments since the placeholder is a <div>
168
// element instead of a <embed>, <object>, ... element.
169
// An <embed> will be centered if the parent has
170
// 'text-align: center' but a <div> will not. This code fixes that.
171
var parentStyle = window.getComputedStyle(flash.parentNode, "");
172
if (parentStyle.getPropertyValue("text-align") == "center") {
173
placeholder.style.marginRight = "auto";
174
placeholder.style.marginLeft = "auto";
178
function flashblockSetTitle(current, placeholder, isStandalone) {
179
// non-null "about:blank" value to prevent OS/2 crashing
180
var fakeURI = "about:blank";
182
placeholder.title = current.src;
183
current.src = fakeURI;
185
else if (current.hasAttribute("src") ||
186
current.hasAttribute("data") ||
187
current.hasAttribute("movie") ) {
188
var srcURI = current.getAttribute("src") ||
189
current.getAttribute("movie") ||
190
current.getAttribute("data") ;
191
placeholder.title = srcURI;
192
if (current.hasAttribute("src")) {
193
placeholder.setAttribute("srcAttribute", current.getAttribute("src"));
194
current.setAttribute("src", fakeURI);
196
if (current.hasAttribute("data")) {
197
placeholder.setAttribute("dataAttribute", current.getAttribute("data"));
198
current.setAttribute("data", fakeURI);
200
if (current.hasAttribute("movie")) {
201
placeholder.setAttribute("movieAttribute", current.getAttribute("movie"));
202
current.setAttribute("movie", fakeURI);
206
var params = current.getElementsByTagName("param");
207
for (var ii = 0; ii < params.length; ii++) {
208
if (params[ii].getAttribute("name") == "movie" &&
209
params[ii].hasAttribute("value")) {
210
placeholder.title = params[ii].value;
211
placeholder.movieParam = [ params[ii], placeholder.title ];
212
params[ii].value = fakeURI;
219
if(flashblockIsWhitelisted())
223
var parent = current.parentNode;
225
// Check parent too (case of working EMBED inside broken OBJECT)
226
if (current.overrideCTV || parentNode.overrideCTV) {
229
current.overrideCTV = true;
231
// Create placeholder div
232
var isStandalone = ("src" in current && current.src == current.ownerDocument.location);
233
var placeholder = flashblockCreatePlaceholder(isStandalone);
235
// Set placeholder image
236
var type = this.flashblockType ? this.flashblockType : "flash"
237
flashblockSetImage(placeholder, type);
239
flashblockStylePlaceholder(current, placeholder, isStandalone);
241
flashblockSetTitle(current, placeholder, isStandalone);
243
// Replace the flash document with a placeholder.
244
var flashblockSetTimeout = nativeMethod(window, "setTimeout");
245
flashblockSetTimeout(flashblockShowPlaceholder, 0);
247
// Change the placeholder background when the mouse enters/exits the div.
248
placeholder.addEventListener("mouseover",
249
function(event) { event.target.style.background = event.target.getAttribute("bgActive"); },
252
placeholder.addEventListener("mouseout",
253
function(event) { event.target.style.background = event.target.getAttribute("bgInactive"); },
257
// Replace the placeholder with the flash document.
258
placeholder.addEventListener("click", flashblockShowFlash, "false");
261
placeholder.setAttribute("tabindex", "0");
262
placeholder.setAttribute("role", "button");
263
placeholder.addEventListener("keypress", flashblockShowFlash, "false");
270
<binding id="director" extends="#flash">
272
<field name="flashblockType">"director"</field>
276
<binding id="authorware" extends="#flash">
278
<field name="flashblockType">"authorware"</field>
282
<binding id="brokenobject">
285
<field name="brokenObject">"yes"</field>
290
//From Jesse's XPCNativeWrapper: http://mavra.perilith.com/~luser/content/native.js
291
function nativeMethod(untrustedObject, methodName)
293
// happier stack traces and faster multiple calls
294
var fun = Components.lookupMethod(untrustedObject, methodName);
298
return fun.apply(untrustedObject, arguments);
302
function flashblockCreatePlaceholder(isStandalone) {
303
// Create placeholder
304
var flashblockCreateElement = nativeMethod(document, "createElementNS");
305
var placeholder = flashblockCreateElement("http://www.w3.org/1999/xhtml", "div");
306
placeholder.isStandalone = isStandalone;
310
// Substitute the animation with a placeholder
311
function flashblockShowPlaceholder() {
312
// Just in case the object has been moved away from under our feet during
313
// the timeout, re-assign the parent node. See bug 13680
314
// parent = current.parentNode;
315
var newParent = current.parentNode;
316
parent = newParent ? newParent : parent;
317
parent.insertBefore(placeholder, current);
318
if(placeholder.isStandalone) {
319
placeholder.flashblock = "frame";
320
if ("StopPlay" in current)
322
if ("LoadMovie" in current)
323
current.LoadMovie(0, "");
324
current.prevWidth = current.width;
325
current.prevHeight = current.height;
326
current.width = current.height = 0;
328
placeholder.flashblock = "normal";
329
parent.removeChild(current);
333
// Show the original animation
334
function flashblockShowFlash(event) {
335
if( event.type == "keypress" && event.keyCode != KeyEvent.DOM_VK_RETURN)
337
event.stopPropagation();
338
if(placeholder.flashblock == "frame") {
339
current.height = current.prevHeight;
340
current.width = current.prevWidth;
341
current.src = placeholder.title;
342
if ("LoadMovie" in current)
343
current.LoadMovie(0, current.src);
345
parent.insertBefore(current, placeholder);
346
if (placeholder.hasAttribute("srcAttribute")) {
347
current.setAttribute("src", placeholder.getAttribute("srcAttribute"));
349
if (placeholder.hasAttribute("movieAttribute")) {
350
current.setAttribute("movie", placeholder.getAttribute("movieAttribute"));
352
if (placeholder.hasAttribute("dataAttribute")) {
353
current.setAttribute("data", placeholder.getAttribute("dataAttribute"));
355
if (placeholder.movieParam) {
356
var mparam = placeholder.movieParam;
357
mparam[0].value = mparam[1];
359
if (placeholder.hasAttribute("embedsrc")) {
360
var embeds = current.getElementsByTagName("embed");
361
if (embeds && embeds.length > 0) {
362
embeds[0].setAttribute("src", placeholder.getAttribute("embedsrc"));
366
parent.removeChild(placeholder);
369
function flashblockIsWhitelisted() {
370
// Check if the page that loaded the Flash site is whitelisted
371
// Thanks to Neil on #mozilla for suggesting this method, I would never have
372
// thought of it on my own. :-)
373
// Lor 20041215: Use "UIEvents" to make it work in post-1.0 FF
374
// (thanks to Neil again)
375
var flashblockEvent = document.createEvent("UIEvents");
377
if(flashblockEvent) {
378
flashblockEvent.initEvent("flashblockCheckLoad", true, true);
379
document.dispatchEvent(flashblockEvent);
380
if(flashblockEvent.getPreventDefault() == true) {
388
function flashblockSetImage(placeholder, type) {
389
var inactiveurl = "url(chrome://flashblock/content/" + type + ".png) no-repeat center";
390
var activeurl = "url(chrome://flashblock/content/flashplay.png) no-repeat center";
391
placeholder.setAttribute("bgInactive", inactiveurl);
392
placeholder.setAttribute("bgActive", activeurl);
393
placeholder.style.background = inactiveurl;
396
function flashblockStylePlaceholder(flash, placeholder, isStandalone) {
397
// If object's size was relative, use that.
398
// Otherwise, set size to minimum 32x32 px
399
placeholder.style.setProperty("min-width", "32px", "important");
400
placeholder.style.setProperty("min-height", "32px", "important");
401
// The size and positioning may come from a class
402
var fClass = flash.getAttribute("class");
404
placeholder.setAttribute("class", fClass);
406
var fStyle = window.getComputedStyle(flash, "");
408
var fWidth = fStyle.getPropertyValue("width");
409
var width = parseInt(flash.width || flash.style.width);
410
if (fWidth && parseInt(fWidth) > 32)
412
else if(flash.width.match("%$"))
415
width = Math.max(width,32) + "px";
418
placeholder.style.width = width;
420
var fHeight = fStyle.getPropertyValue("height");
421
var height = parseInt(flash.height || flash.style.height);
422
if (fHeight && parseInt(fHeight) > 32)
424
else if(flash.height.match("%$"))
425
height = flash.height;
427
height = Math.max(height,32) + "px";
430
placeholder.style.height = height;
432
// Add styling rules to placeholder div.
433
placeholder.style.border = "1px solid #dfdfdf";
434
placeholder.style.cursor = "pointer";
435
placeholder.style.overflow = "hidden";
436
var disp = fStyle.getPropertyValue("display");
437
placeholder.style.display = disp == "block" ? "block" : "inline-block";
438
placeholder.style.setProperty("visibility", "visible", "important");
440
// The size of the placeholder should include borders too,
441
// otherwise scrollbars appear for blocked standalone objects
442
placeholder.style.MozBoxSizing = "border-box";
444
// Make some style adjustments since the placeholder is a <div>
445
// element instead of a <embed>, <object>, ... element.
446
// An <embed> will be centered if the parent has
447
// 'text-align: center' but a <div> will not. This code fixes that.
448
var parentStyle = window.getComputedStyle(flash.parentNode, "");
449
if (parentStyle.getPropertyValue("text-align") == "center") {
450
placeholder.style.marginRight = "auto";
451
placeholder.style.marginLeft = "auto";
455
function flashblockSetTitle(current, placeholder, isStandalone) {
456
// non-null "about:blank" value to prevent OS/2 crashing
457
var fakeURI = "about:blank";
459
placeholder.title = current.src;
460
current.src = fakeURI;
462
else if (current.hasAttribute("src") ||
463
current.hasAttribute("data") ||
464
current.hasAttribute("movie") ) {
465
var srcURI = current.getAttribute("src") ||
466
current.getAttribute("movie") ||
467
current.getAttribute("data") ;
468
placeholder.title = srcURI;
469
if (current.hasAttribute("src")) {
470
placeholder.setAttribute("srcAttribute", current.getAttribute("src"));
471
current.setAttribute("src", fakeURI);
473
if (current.hasAttribute("data")) {
474
placeholder.setAttribute("dataAttribute", current.getAttribute("data"));
475
current.setAttribute("data", fakeURI);
477
if (current.hasAttribute("movie")) {
478
placeholder.setAttribute("movieAttribute", current.getAttribute("movie"));
479
current.setAttribute("movie", fakeURI);
483
var params = current.getElementsByTagName("param");
484
for (var ii = 0; ii < params.length; ii++) {
485
if (params[ii].getAttribute("name") == "movie" &&
486
params[ii].hasAttribute("value")) {
487
placeholder.title = params[ii].value;
488
placeholder.movieParam = [ params[ii], placeholder.title ];
489
params[ii].value = fakeURI;
496
if(flashblockIsWhitelisted())
500
var parent = current.parentNode;
502
// Check parent too (case of working EMBED inside broken OBJECT)
503
if (current.overrideCTV || parentNode.overrideCTV) {
506
current.overrideCTV = true;
508
var params = this.getElementsByTagName("param");
510
for (var ii = 0; ii < params.length; ii++) {
511
var pvalue = params[ii].getAttribute("value");
512
if (/\.swf/i.test(pvalue)) {
517
var embeds = this.getElementsByTagName("embed");
518
for (var jj = 0; jj < embeds.length; jj++) {
519
var embed = embeds[jj];
520
if (/x-shockwave-flash/i.test(embed.getAttribute("type")) ||
521
/\.swf/i.test(embed.getAttribute("src"))) {
526
if (!isFlash) {return;}
528
// Create placeholder div
529
var isStandalone = ("src" in current && current.src == current.ownerDocument.location);
530
var placeholder = flashblockCreatePlaceholder(isStandalone);
532
// Set placeholder image
533
var type = this.flashblockType ? this.flashblockType : "flash"
534
flashblockSetImage(placeholder, type);
536
flashblockStylePlaceholder(current, placeholder, isStandalone);
538
flashblockSetTitle(current, placeholder, isStandalone);
540
// Replace the flash document with a placeholder.
541
var flashblockSetTimeout = nativeMethod(window, "setTimeout");
542
flashblockSetTimeout(flashblockShowPlaceholder, 0);
544
// Change the placeholder background when the mouse enters/exits the div.
545
placeholder.addEventListener("mouseover",
546
function(event) { event.target.style.background = event.target.getAttribute("bgActive"); },
549
placeholder.addEventListener("mouseout",
550
function(event) { event.target.style.background = event.target.getAttribute("bgInactive"); },
554
// Replace the placeholder with the flash document.
555
placeholder.addEventListener("click", flashblockShowFlash, "false");
558
placeholder.setAttribute("tabindex", "0");
559
placeholder.setAttribute("role", "button");
560
placeholder.addEventListener("keypress", flashblockShowFlash, "false");
567
<binding id="sifr-replaced">
571
event = document.createEvent("UIEvents");
574
event.initEvent("flashblockCheckLoad", true, true);
575
document.dispatchEvent(event);
576
if(event.getPreventDefault() == true) {
582
this.style.height = 0;
583
this.style.width = 0;
584
this.style.setProperty("display", "none", "important");
585
this.style.position ="absolute";
586
this.style.overflow ="hidden";
592
<binding id="sifr-alternate">
596
var event = document.createEvent("UIEvents");
599
event.initEvent("flashblockCheckLoad", true, true);
600
document.dispatchEvent(event);
601
if(event.getPreventDefault() == true) {
607
this.style.setProperty("visibility", "visible", "important");
608
this.style.setProperty("display", "block", "important");
609
this.style.setProperty("left", "auto", "important");
610
this.style.setProperty("top", "auto", "important");
611
this.style.setProperty("height", "auto", "important");
612
this.style.setProperty("width", "auto", "important");
613
//this.style.position = "static";