Flash blocking with user stylesheet
Saturday, 27. November 2004, 01:22:19
Entrepid Opera user Fabian has created this very cool Flash-blocker. In involves nothing more than adding a few lines to your user stylesheet:
embed[type="application/x-shockwave-flash"] {content:"Flash"; outline: 1px dotted gray; color: gray; background: black}
embed[type="application/x-shockwave-flash"].zichtbaar {content: normal; outline: none}
body:before {
position: absolute; visibility: hidden;
background-image: url("javascript:(function(){window.onclick=function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar'};})()");
content:""}
This will replace Flash movies with a black area with the word Flash on it, and clicking on the area will play the Flash movie. Depending on the HTML code of the page, the replacement block might collapse dimensions. This blocker will only block display, it wil not block loading the Flash, so on clicking the Flash immediately starts playing.
Get the code from this zip to be sure you are not fooled by linebreaks:
<http://my.opera.com/forums/attachment.php?postid=744450>
Maybe I should write something about the easiest way to work with custom stylesheets. Later!
M.
By Moose, # 27. November 2004, 01:22:19
If you think JavaScript is dangerous, you should disable it. It doesn't matter whether you embed the script in a document with a script element, or in a more roundabout way with a stylesheet like this.
As it *is* a rather esoteric method, I doubt it will become popular. It is used in a user stylesheet here because there is no other way to bind behavior to third-party documents. If we would have userscript support, it wouldn't be needed.
By Rijk, # 27. November 2004, 01:22:19
Do they use Flash at gmail.com? I don't think so, but after comment out the lines I added, it comes to work again on 760TP3.
By saito, # 27. November 2004, 01:22:19
For a while, till 760 Release, will try to use 'Open in Firexxx' at GMail.
By saito, # 27. November 2004, 01:22:19
The JS sets window.onclick - that probably overwrites GMail's own window.onclick and breaks things. The script should use
window.addEventListener('click' , function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar'}, false)
By hallvors, # 27. November 2004, 01:22:19
This script does the trick, thank you. :)
By Gspusi, # 27. November 2004, 01:22:19
By kiwibird, # 27. November 2004, 01:22:19
embed[type="application/x-shockwave-flash"] {content:"Flash"; outline: 1px dotted gray; color: gray; background: black}
embed[type="application/x-shockwave-flash"].zichtbaar {content: normal; outline: none}
body:before {
position: absolute; visibility: hidden;
/*
background-image: url("javascript:(function(){window.onclick=function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar'};})()");
*/
background-image: url("javascript:(function(){window.addEventListener('click', function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar'}, false);})");
content:""
}
By kiwibird, # 27. November 2004, 01:22:19
background-image: url("javascript:window.addEventListener('click', function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar';}, false)");
By jebediah, # 27. November 2004, 01:22:19
By leuce, # 7. October 2005, 08:09:46
embed[type="application/x-shockwave-flash"] {content:"Flash"; outline: 1px dotted gray; color: gray; background: black}
embed[type="application/x-shockwave-flash"].zichtbaar {content: normal; outline: none}
body:before {
position: absolute; visibility: hidden;
background-image: url("javascript:window.addEventListener('click', function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar';}, false)");
content:""}
pretty much the same as listed above (i changed to window.addeventlistener since i was having problems with GMail too). however, i installed the opera 9 preview and a problem appeared. when browsing the my.opera.com forums, every time a page (of these forums) loads, opera takes up 100% of the cpu for about 5 seconds. i've isolated the problem to this piece of code above (as in, removing it from my user.css file means no problems, and having it in means they exist). can anyone look into it and find a solution? thank you inadvance.
EDIT: the problem was not present under opera 8.5 with the same setup.
EDIT 2: i believe the problem can be found in the http://my.opera.com/community/js/menu.js file, which also has something like addeventlistener in it. more than that i cannot help, i never wrote 2 lines of code in my life, but perhaps someone could alter the flashblock code a little so it works again?
By villiansv, # 29. October 2005, 02:21:40
I have altered the css code to include the same image that comes with the Firefox Flashblock extension for Opera 8.51.
embed[type="application/x-shockwave-flash"] {
content: url(http://img467.imageshack.us/img467/9899/flashblock2tp.gif);
}
embed[type="application/x-shockwave-flash"].zichtbaar {content: normal; outline: none}
body:before {
position: absolute; visibility: hidden;
background-image: url("javascript:window.addEventListener('click', function(){var srcElem=window.event.srcElement;var tag=srcElem.tagName;if(tag=='EMBED') srcElem.className='zichtbaar';}, false)");
content:""}
Create a css file in your Opera\styles directory and name it user.css; paste the above code into this file and save it. To enable the code, you have to go to Tools and then Preferences. Click on Advanced and then the Style Options button. Navigate to the user.css file you just created and select it. Ensure that the My Styles check boxes are checked and then click on OK and then OK again. Restart the browser and the Flashblock button will appear when flash banners are encountered; you can click on them to play the flash.
By anonymous user, # 14. December 2005, 04:05:27
Thanks for the tip about flash blocking! It takes care of those that can't be blocked by disabling Flash.
BTW - how does Flash load on a site if not by javascript? I've searched the page code in such cases and can never see a reference to Shock, Flash, .swf
thanks,
rich
By anonymous user, # 15. April 2006, 04:36:13
Flash can be embedded with the EMBED or OBJECT elements, where the URL to the actual flash should be visible somewhere in the source code as an attribute on or nested in (PARAM element) these elements.
By Rijk, # 15. April 2006, 16:26:35
CAN ANYBODY - P L E A S E - TELL ME, HOW TO REMOVE THE OPERA OUTLINE FROM MY BUTTONS???
I am building a page with enhanced accessibility functions, but Opera is giving me a major headache.
Is there anyway ( Opera way ) to remove the default outlining style and especially the FOCUS navy selection color from my navigation buttons please?
Many thanks in advance.
By TroyIII, # 7. July 2008, 06:07:47
By Rijk, # 7. July 2008, 09:28:37