Watching videos on YouTube can be really annoying. On a slow netbook the page containing the video takes forever to load, and then there are these pesky and long intro ads. For a demo let's take this video as example.
Wouldn't it be much nicer to view the video without delay and without ads?. Can be done. Try the same video with this link.
Much better, isn't it? And notice how the video always fills the whole browser page. Scales nicely when the window is resized and reaches (almost) the same size as in fullscreen mode when the browser window is maximized.
The 2nd link type uses YouTube's special URL for embedded videos. Using a little script I can redirect almost any "normal" YT link to the fast and ad-free second type:
Code: Select all
#!/bin/sh
BROWSER=defaultbrowser
YTURL=$(xclip -o -sel clip) || YTURL=$(xsel -b)
(($?)) && exec Xdialog -msg "xclip or xsel not installed" x
case $YTURL in
*youtube.com*v%3D*) VIDID=${YTURL#*v%3D};;
*youtube.com*v=*) VIDID=${YTURL#*v=};;
*youtu.be* ) VIDID=${YTURL#*.be/};;
* ) exec Xdialog -msg "Not a recognized YouTube URL:\n\n${YTURL::50}" x;;
esac
VIDID=${VIDID::11}
exec $BROWSER "https://www.youtube.com/embed/$VIDID?autoplay=1"
- Copy the code into a file and make the file executable.
- Drag the file onto the desktop to create a desktop icon
This is sufficient to start the script with the mouse, but it's more convenient to use a keyboard shortcut when the desktop is covered, so
, right-click the created icon and select "Edit Item"
- Push the "(click to set)"button and enter a keyboard shortcut for the script. I use Ctrl+Shift+A
Now let's use the script:
Go to a search engine, e.g. Google or DuckDuckGo or even YouTube's search, and search for something. Clicking on the top "Videos" category normally provides many YT links.
Do not left click on such a link! Instead right click to trigger the context menu.
When using Palemoon the menu looks like in the screenshot. We need to copy the link address to the clipboard, which (in Palemoon!) can be done by selection "Copy Link Location" or by pressing the A key (note the underlined a in the menu).
Then enter Ctrl+Shift+A. This will start the script. The script reads YT URL from the clipboard, then converts the URL into the "embedded" type and finally passes it to the browser. If the browser is Palemoon a new tab will open and the video will start.
The videos end with a couple of preview images for related videos. YouTube tries hard to lure users from an embedded video to the main site. OK, fair enough. But of course those follow up videos can also be viewed stress free using above script. All that has to be done is saving the URL into the clipboard.
Limitations:
Though most uploaders allow their YT videos to be embedded, some don't (e.g. ABC Australia, Fox and some music channels ). In this case you will see the message "Video unavailable" and have to use the "full featured" website.
That's all. Have fun!
[EDIT] Enhanced version
Apart from YouTube videos this enhanced script additionally supports Dailymotion videos (see here for details):
Code: Select all
#!/bin/sh
BROWSER=defaultbrowser
CLIP=$(xclip -o -sel clip) || CLIP=$(xsel -b)
(($?)) && exec Xdialog -msg "xclip or xsel not installed" x
case $CLIP in
*youtube.com*v%3D*) SITE=YT; VIDID=${CLIP#*v%3D} ;;
*youtube.com*v=*) SITE=YT; VIDID=${CLIP#*v=} ;;
*youtu.be*) SITE=YT; VIDID=${CLIP#*.be/} ;;
*youtube.com/embed/*) SITE=YT; VIDID=${CLIP#*embed/} ;;
*dailymotion.com/video*) SITE=DM; VIDID=${CLIP#*video/} ;;
*dailymotion.com%2Fvideo%2F*) SITE=DM; VIDID=${CLIP#*video%2F};;
esac
case $SITE in
YT) VIDID=${VIDID::11}
CMD="https://www.youtube.com/embed/$VIDID?autoplay=1" ;;
DM) VIDID=${VIDID::7}; VIDID=${VIDID%&} #sometimes only 6 digit ID, with trailing &
CMD="https://www.dailymotion.com/embed/video/$VIDID?autoplay=1" ;;
*) gxmessage -name "$0" -c -fn 'bold 11' -bg '#f00' -fg '#fff' -de okay $'\n Clipboard content is not a valid video URL \n'
exit ;;
esac
exec "$BROWSER" "$CMD"