Flash Controls (Pause button and a seek bar under Flash)
|
|
A) "Add FlashControls" it a "blummy" bookmarklet go to: http://www.blummy.com/config.php and search for "Add FlashControls" http://www.blummy.com/modify.php?id=3128&return... blummy wont let me to copy it so i just drag and drop it directly from the blummy popup field to my "Bookmarks Toolbar Folder" (dunno if you understand what i just wrote... nvm) blummy bookmarklet: javascript:( function(){ setTimeout(initFlashControls,100); function initFlashControls() { var count=0; function tt(elem){if(typeof elem.TotalFrames!="undefined"){ var controls=getElementsByClassName(document,'div','flashseekbar'); if(controls.length>0) { removeFlashControls(controls); } else addFlashControls(elem); ++count;} }var i,x; for(i=0; x=document.getElementsByTagName("object")[i]; ++i)tt(x); for(i=0; x=document.getElementsByTagName("embed")[i]; ++i)tt(x); if(!count)alert("No scriptable flash on this page."); } /* Flash Seek Bar bookmarklet - codemonkey Edition 1.0 Flash seek bar originally by Jesse Ruderman*/ function removeFlashControls(controls){for (var i=0;i<controls><arrelements>
___________________________________ B) which is an enhanced clone of "seek bar" http://www.squarefree.com/bookmarklets/flash.html you can just copy it (seek bar) from its site with no problem! ;) javascript:(function(){setTimeout(initFlashControls,100);function initFlashControls(){var count=0;function tt(elem){if(typeof elem.TotalFrames!="undefined"){addFlashControls(elem);++count;}}var i,x;for(i=0;x=document.getElementsByTagName("object")[i];++i)tt(x);for(i=0;x=document.getElementsByTagName("embed")[i];++i)tt(x);if(!count)alert("No scriptable flash on this page.");}function addFlashControls(flash){var controlsDiv=document.createElement("div");var where=flash;while(where.parentNode.tagName.toLowerCase()=="object")where=where.parentNode;where.parentNode.insertBefore(controlsDiv,where.nextSibling);var table=document.createElement("table");controlsDiv.appendChild(table);var row=table.insertRow(-1);var pauseButton=document.createElement("button");pauseButton.appendChild(document.createTextNode("Pause"));var buttonCell=row.insertCell(-1);buttonCell.appendChild(pauseButton);var slider=row.insertCell(-1);slider.width="100%";var visibleSlider=document.createElement("div");visibleSlider.style.position="relative";visibleSlider.style.height="10px";visibleSlider.style.width="100%";visibleSlider.style.MozBorderRadius="4px";visibleSlider.style.background="#aaa";slider.appendChild(visibleSlider);var thumb=document.createElement("div");thumb.style.position="absolute";thumb.style.height="20px";thumb.style.width="10px";thumb.style.top="-5px";thumb.style.MozBorderRadius="4px";thumb.style.background="#666";visibleSlider.appendChild(thumb);var sliderWidth;var paused=false;var dragging=false;table.width=Math.max(parseInt(flash.width)||0,400);addEvent(pauseButton,"click",pauseUnpause);addEvent(slider,"mousedown",drag);addEvent(slider,"drag",function(){return false;});window.setInterval(update,30);function pauseUnpause(){paused=!paused;pauseButton.style.borderStyle=paused?"inset":"";if(paused)flash.StopPlay();else flash.Play();}function update(){sliderWidth=parseInt(getWidth(slider)-getWidth(thumb));if(!paused&&!dragging)thumb.style.left=parseInt(flash.CurrentFrame()/totalFrames()*sliderWidth)+"px";}function dragMousemove(e){var pageX=e.clientX+document.body.scrollLeft;var pos=bounds(0,pageX-getX(slider)-5,sliderWidth);var frame=bounds(1,Math.ceil(totalFrames()*pos/sliderWidth),totalFrames()-2);thumb.style.left=pos+"px";flash.GotoFrame(frame);}function release(e){removeEvent(document,"mousemove",dragMousemove);removeEvent(document,"mouseup",release);if(!paused)flash.Play();dragging=false;}function drag(e){addEvent(document,"mousemove",dragMousemove);addEvent(document,"mouseup",release);dragging=true;dragMousemove(e);}function bounds(min,val,max){return Math.min(Math.max(min,val),max);}function totalFrames(){if(typeof flash.TotalFrames=="number")return flash.TotalFrames;else if(typeof flash.TotalFrames=="function")return flash.TotalFrames();else return 1;}function getWidth(elem){if(document.defaultView&&document.defaultView.getComputedStyle)return parseFloat(document.defaultView.getComputedStyle(elem,null).getPropertyValue("width"));else return parseFloat(elem.offsetWidth);}function getX(elem){if(!elem)return 0;return(elem.offsetLeft)+getX(elem.offsetParent);}function addEvent(elem,eventName,fun){if(elem.addEventListener)elem.addEventListener(eventName,fun,false);else elem.attachEvent("on"+eventName,fun);}function removeEvent(elem,eventName,fun){if(elem.addEventListener)elem.removeEventListener(eventName,fun,false);else elem.detachEvent("on"+eventName,fun);}}})()
___________________________________ C) will someone here patch this function into a userscript??? Regards. Simon |
|
|
Simon, Allow me to answer C first. Yes, someone can. This person is you. The first step is to create a new notepad file on your desktop. Open it, and then add the script's metadata. You can (read: should) read about it at this site: http://diveintogreasemonkey.org/helloworld/meta... When you're done, you should have something like this: // ==UserScript==
as the contents of your notepad file. Give yourself a few lines for spacing, then copy and paste either (not both) of your above functions into notepad. You will need to remove the very beginning "javascript:" because this is what tells your browser to execute the following as javascript; it is completely unnecessary in a greasemonkey script. The next step is to save it. It must be saved as [something].user.js and so I would suggest saving it as FlashControls.user.js (save to your desktop). Lastly, right click on the FlashControls.user.js script and open with firefox. You should see a popup asking you if you want to install this script; click install and you should be all set. Hope this helped,
|
|
|
Nop!? it's not working, and it keeps alert me "No scriptable flash on this page." even when i got flash, or maybe its only me!? __________________________________________________________ squarefree.com bookmarklet: // ==UserScript==
// @name FlashControls
// @namespace http://www.squarefree.com/bookmarklets/flash.html
// @description Creates a pause button and a seek bar under Flash movies
// @include *
// @exclude dunno XD
// ==/UserScript==
(function(){setTimeout(initFlashControls,100);function initFlashControls(){var count=0;function tt(elem){if(typeof elem.TotalFrames!="undefined"){addFlashControls(elem);++count;}}var i,x;for(i=0;x=document.getElementsByTagName("object")[i];++i)tt(x);for(i=0;x=document.getElementsByTagName("embed")[i];++i)tt(x);if(!count)alert("No scriptable flash on this page.");}function addFlashControls(flash){var controlsDiv=document.createElement("div");var where=flash;while(where.parentNode.tagName.toLowerCase()=="object")where=where.parentNode;where.parentNode.insertBefore(controlsDiv,where.nextSibling);var table=document.createElement("table");controlsDiv.appendChild(table);var row=table.insertRow(-1);var pauseButton=document.createElement("button");pauseButton.appendChild(document.createTextNode("Pause"));var buttonCell=row.insertCell(-1);buttonCell.appendChild(pauseButton);var slider=row.insertCell(-1);slider.width="100%";var visibleSlider=document.createElement("div");visibleSlider.style.position="relative";visibleSlider.style.height="10px";visibleSlider.style.width="100%";visibleSlider.style.MozBorderRadius="4px";visibleSlider.style.background="#aaa";slider.appendChild(visibleSlider);var thumb=document.createElement("div");thumb.style.position="absolute";thumb.style.height="20px";thumb.style.width="10px";thumb.style.top="-5px";thumb.style.MozBorderRadius="4px";thumb.style.background="#666";visibleSlider.appendChild(thumb);var sliderWidth;var paused=false;var dragging=false;table.width=Math.max(parseInt(flash.width)||0,400);addEvent(pauseButton,"click",pauseUnpause);addEvent(slider,"mousedown",drag);addEvent(slider,"drag",function(){return false;});window.setInterval(update,30);function pauseUnpause(){paused=!paused;pauseButton.style.borderStyle=paused?"inset":"";if(paused)flash.StopPlay();else flash.Play();}function update(){sliderWidth=parseInt(getWidth(slider)-getWidth(thumb));if(!paused&&!dragging)thumb.style.left=parseInt(flash.CurrentFrame()/totalFrames()*sliderWidth)+"px";}function dragMousemove(e){var pageX=e.clientX+document.body.scrollLeft;var pos=bounds(0,pageX-getX(slider)-5,sliderWidth);var frame=bounds(1,Math.ceil(totalFrames()*pos/sliderWidth),totalFrames()-2);thumb.style.left=pos+"px";flash.GotoFrame(frame);}function release(e){removeEvent(document,"mousemove",dragMousemove);removeEvent(document,"mouseup",release);if(!paused)flash.Play();dragging=false;}function drag(e){addEvent(document,"mousemove",dragMousemove);addEvent(document,"mouseup",release);dragging=true;dragMousemove(e);}function bounds(min,val,max){return Math.min(Math.max(min,val),max);}function totalFrames(){if(typeof flash.TotalFrames=="number")return flash.TotalFrames;else if(typeof flash.TotalFrames=="function")return flash.TotalFrames();else return 1;}function getWidth(elem){if(document.defaultView&&document.defaultView.getComputedStyle)return parseFloat(document.defaultView.getComputedStyle(elem,null).getPropertyValue("width"));else return parseFloat(elem.offsetWidth);}function getX(elem){if(!elem)return 0;return(elem.offsetLeft)+getX(elem.offsetParent);}function addEvent(elem,eventName,fun){if(elem.addEventListener)elem.addEventListener(eventName,fun,false);else elem.attachEvent("on"+eventName,fun);}function removeEvent(elem,eventName,fun){if(elem.addEventListener)elem.removeEventListener(eventName,fun,false);else elem.detachEvent("on"+eventName,fun);}}})()
__________________________________________________________ blummy bookmarklet: no alert in here :P // ==UserScript==
// @name FlashControls
// @namespace http://www.squarefree.com/bookmarklets/flash.html
// @description Creates a pause button and a seek bar under Flash movies
// @include *
// @exclude dunno XD
// ==/UserScript==
( function(){ setTimeout(initFlashControls,100); function initFlashControls() { var count=0; function tt(elem){if(typeof elem.TotalFrames!="undefined"){ var controls=getElementsByClassName(document,'div','flashseekbar'); if(controls.length>0) { removeFlashControls(controls); } else addFlashControls(elem); ++count;} }var i,x; for(i=0; x=document.getElementsByTagName("object")[i]; ++i)tt(x); for(i=0; x=document.getElementsByTagName("embed")[i]; ++i)tt(x); if(!count)alert("No scriptable flash on this page."); } /* Flash Seek Bar bookmarklet - codemonkey Edition 1.0 Flash seek bar originally by Jesse Ruderman*/ function removeFlashControls(controls){for (var i=0;i<controls>http://www.snook.ca/jonathan Add-ons by Robert Nyman, http://www.robertnyman.com*/function getElementsByClassName(oElm, strTagName, strClassName){var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/-/g, "-"); var oRegExp = new RegExp("(^|s)" + strClassName + "(s|$)"); var oElement; for(var i=0; i</controls><arrelements></arrelements>
__________________________________________________________ By the way, I tried "bookmarklets to user scripts" and it didn't work (same result) Somehow I cant fined it anywhere, so... (this is from my machine, I got it since 26.2.2007) // ==UserScript==
// @namespace http://www.squarefree.com/userscripts
// @name Bookmarklets to User Scripts
// @description Lets you install any bookmarklet as a user script.
// @include http://www.squarefree.com/bookmarklets/*
// ==/UserScript==
// Ideas for improvements:
// * Pretty-print the bookmarklet using something like http://subsimple.com/bookmarklets/format.js but without the bugs.
var i, bookmarklet, bookmarkletName, img, a;
for (i = 0; bookmarklet = document.links[i]; ++i)
{
if (bookmarklet.protocol == "javascript:")
{
bookmarkletName = bookmarklet.textContent;
img = document.createElement("img");
img.src = "data:image/gif;base64,R0lGODlhEAAQAOYAAM6KjNaanO%2Byte%2B6vffDxr2anGtZWq2qraWipXt5e4SChHt9e5SWlISGhK2uraWmpb1RALVNAK1JAKVJAJRBAMZdEL1ZEIxJGIxdOb1NAKVFAJxBAJQ8AM5dELVVEJxNGJRRIYxNIb1pMaVlOa1tQq1JCKVNGJRJGKVVIZxRIZRNIYxVMbV5UoxpUoxtWpQ8CJxNIbVhMZxZMZRVMaV1Wr1hMZRdQr1pQs55UqVhQsZ1UtZ9Ws59Wr1xUs55WrVtUsZ1Wq1pUpRdSsaCa5SOjM6Ca855Y8Z9a86Gc86Cc715a96ajNaOhN6WjNaSjIx1c4RlY9aOjN6enM6mpd62teempf%2FHxv%2FPzgAAAP%2F%2F%2FwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAFkALAAAAAAQABAAQAewgFmCg4SFgi8eAVdYWIuNARUaGA2CQQNXV1U3VZgDOTSDSVYGjKWMBlZIQgiEGxqvEhIaM4QiEEeYmAS5V0MRGgpZUbzEmE4jD4IhFjxNAs9NOx0nT4ZZIBwcFCnWgj9LTDESNUxLPS6DLBJKvAC8ShMXWSQaQJiMjpg%2BGh%2BUHkWcilUx0mGFgywCqGApQGwKlikCVBzIIkOHlGJXpOCAAYVQCxQaIkTIUMKEDSKDAgEAOw%3D%3D";
img.alt = "Install " + bookmarkletName + " as a user script.";
img.title = img.alt;
img.style.border = "none";
// hack for http://www.squarefree.com/bookmarklets/
img.style.display = "inline";
a = document.createElement("a");
a.href = "data:text/javascript;charset=utf-8,"
+ "// ==UserScript==%0A"
+ "// @namespace http://www.squarefree.com/bookmarklets-to-user-scripts%0A"
+ "// @name " + bookmarkletName + "%0A"
+ "// @description Runs the " + bookmarkletName + " bookmarklet from " + location.href + "%0A"
+ "// ==/UserScript==%0A"
+ "%0A"
+ encodeURIComponent(bookmarklet.href)
+ "%0A//.user.js";
a.appendChild(img);
a.appendChild(document.createTextNode(" "));
bookmarklet.parentNode.insertBefore(a, bookmarklet);
// We just added a link, and document.links is live, so...
++i;
}
}
______________________________________________________________ One more thing: maybe we can get some help from the following scripts, which can recognize flash, even when "JavaScript" is off (e.g when NoScript is in use...) 1) removeFLash: http://userscripts.org/scripts/show/888
Anyway, Thanks for your reply "Joel H" and Happy Passover! |
|
|
Now that you break the layout in this thread, you might also want to check Force Wrap user script, which is based on Jesse Ruderman's Force Wrap bookmarklet. /shameless self promotion |
|
|
LouCypher wrote "/shameless self promotion" hahaha, very funny!! :) By the way I saw it already you know... I just thinking if you are able to help us to carry out my suggestion! ;) 63 scripts... well, lets make it 64 :D |
|
|
:) Word-breaking/pre-scrolling code has been written for this site, just not brought live yet. |
|
|
"Word-breaking/pre-scrolling" what do you mean by that (I really don't understand >.<) Sorry !? |
|
|
Simon, Most of the other threads wrap very nicely. You may notice some longer lines of text, specifically the scripts, look like they just continue very far to the right. This is caused by using long, continuous lines of text (no spaces). Word-breaking and pre-scrolling are two methods of ensuring that longer text like that doesn't mess up the page formatting, but will also be displayed in a manner that is true to the original intent (sometimes lines really do need to be that long). In your case, it was possible to break up your script into a few dozen different lines and it would work just as well, but it's an extra step and another thing to explain to break it up; additionally, you had already posted the script source before you could be aware of its impact. In short, Henrik is trying to keep the site looking clean, without extending important text behind that infernal ad bar on the right (which remind me, i need to find/write a script to remove that...) -Joel |
|
|
I don't believe it!! I wanted to talk about a new script that put "a seek bar" under flash objects instead of pressing Jesse Ruderman's seek bar bookmarklet, and in return i get a full conversation (even the Administrator Henrik Nyh) about LouCypher's Force Wrap!! I mean, thank you Joel H for the explanation, but what about my suggestion??? gee :D |
|
|
Simon, It really wasn't that far off topic, and besides, you asked about it, too. 'Nop!? it's not working, and it keeps alert me "No scriptable flash on this page." even when i got flash, or maybe its only me!?' Without even installing or running either script, I have found a problem. Re-read the diveintogreasemonkey link I sent earlier,
Happy Passover -Joel |
|
|
Thanks Joel! I'm very busy lately, but I'll see what I can do 1) If you still have problems, I suggest going over the source code and commenting every line so that you understand it.
2) If nothing else, this will be a good learning experience. good long learning experience note: I finished my programming exams at my high school with 85 out of 100, but it was more then 1 year ago as I said "I'll see what I can do" as soon as I can ;) Simon |
|
|
Maybe this could help??? Tom's FlashControl
|
|
|
I think it should help as it is actually the same project xD
|
