Professional Documents
Culture Documents
/* CHANGELOG
1.2.87 (1/22/2014)
- fixed odd internal error that made the player not show
- fixed problem with "Red Bar" not being disabled properly
1.2.86 (12/21/2013)
- fixed Large player button (as far as I can tell)
- added Automatic quality option (the YouTube default)
- switched the DASH option default to enabled
this is really what the script was made for... auto-buffering
1.2.85 (12/11/2013)
- added a script icon
- added a "Player Color Scheme" option
- fixed bug with SPF not being de-activated properly in non-Firefox browsers
- fixed volume bug
- fixed adding time in url bug. it will now skip to the right portion of the
video
- changed internal name of the "Activation Mode" option. shouldn't affect the
user
- the script doesn't add any javascript to the page anymore
it uses onYouTubePlayerReady to detect when the player is ready;
it's much more performant than an interval
1.2.84 (10/31/2013)
- added primitive type checking when copying ytplayer.config.args into the
flashvars.
this fixes the issue with Flashgot and possibly other add-ons
- fixed non-activation by moving the _spf_state check to the top of init.
this disables SPF on every YouTube page now, and should make the script
activate correctly
- changed all RegExp test methods to match. match seems more consistent.
I've had cases where test doesn't work, but match does
1.2.83 (10/28/2013)
- added auto HD, volume, and more activation modes for html5 (thanks to youtube
updating its API)
- changed the default quality to 1080p
- changed the wording of some options
- changed the "Disable Dash Playback" option to false for default
- disabled SPF (aka Red Bar feature) completely until I get playlists working
better
- changed the setPref prototype function to a regular function
1.2.82 (9/5/2013)
- added support for older Firefox versions (tested on 3.6)
- added a new option to disable 'dash' playback (videos loading in
blocks/pieces)
- re-added ad removal feature (experimental for now)
1.2.81
- fixed HTML5 support. YT changed tag names so the script got confused
- made a few minor performance tweaks
- fixed 'play symbol in title' bug in autobuffer mode (it would show playing,
even though it's paused/buffering)
1.2.80
- switched to JSL.setInterval for consistency and drift accommodation
- visual tweaks to:
msg().
the rest of the page now dims while the msg box is visible
changed the spacing of most of the elements
changed the font sizes and the font (Arial)
added a close button instead of requiring a double click
made it auto-open the options screen when the msg is closed
GM_config.
made the background color more mellow and moved the section title near
the middle
1.2.79
- adjusted to the new play symbol in the youtube title feature
- Changed margins on the settings button when in footer
- Switched JSL/pushState checking order.
Previously in 1.2.78, if JSL didn't exist or wasn't @required, the script
would still loop every 500ms to re-set the pushState method, even though
the
script wasn't going to be running.
I switched that so that JSL has to exist before the script does anything.
1.2.78
- Fixed bug where options button wasn't getting added to the footer with the
new Red Bar YT feature
1.2.77
- Adapted to the new YouTube feature that uses HTML5's history.pushState to
load videos
- Small fixes here and there
- Excluded (with RegExp) pages without videos on them
- Fixed GM_config.log()
- Declared all variables at the beginning of functions
- Made finding the video player a little more reliable
- Make 'autoplay on playlists' work with HTML5 videos
1.2.76
- Added new quality option ('1080p+' - for anything higher than 1080p)
1.2.75
- Added a new option (to move option button to page footer)
- Added a new option (to autoplay on playlists regardless of auto[play/buffer]
setting)
- Added a first time user message box
- Fixed bug with GM_config's [set/get]Value functions. Chrome/Opera were not
using localStorage before this update
1.2.74
- Adapted to YouTube's new layout
1.2.73
- Added compatibility for user pages
1.2.72
- Made it fully working again in Opera & Chrome
- Switched from setInterval to setTimeout due to instability
- Added an anonymous function wrapper
1.2.71
- Added compatibility for HTML5
*/
// run the script in an IIFE, to hide its variables from the global scope
(function (undefined) {
'use strict';
function toNum(a) {
return parseInt(a, 10);
}
// msg by JoeSimmons
function msg(infoObject) {
function msg_close(event) {
event.preventDefault();
document.getElementById(box_id_name).style.display = 'none';
if (box == null) {
JSL.addStyle('' +
'@keyframes blink { ' +
'50% { color: #B95C00; } ' +
'}\n\n' +
'#' + box_id_name + ' .msg-header { ' +
'animation: blink 1s linear infinite normal; ' +
'}' +
'');
document.body.appendChild(
JSL.create('div', {id : box_id_name, style : 'position: fixed; top:
0; left: 0; width: 100%; height: 100%; z-index: 999999; background-color: rgba(0,
0, 0, 0.6);'}, [
// main box
JSL.create('div', {id : box_id_name + '_box', style :
'position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; padding-top:
50px; background-color: #E9E9E9; border: 3px double #006195;'}, [
// header
JSL.create('div', {style : 'margin: 0 auto; padding-bottom:
40px; color: #F07800; font-size: 21pt; font-family: Arial, Verdana, "Myriad Pro";
font-weight: normal; text-shadow: 2px 2px 4px #C7C7C7; text-align: center;',
'class' : 'msg-header', textContent : title}),
// text (message)
JSL.create('div', {innerHTML : infoObject.text, style :
'text-align: center; margin: 0 auto; padding-top: 39px; border-top: 1px solid
#B0B0B0; color: #000000; font-size: 11pt; font-family: Arial, Verdana, "Myriad
Pro"; font-weight: normal; text-shadow: 0 0 8px #AEAEAE;'}),
// close button
JSL.create('div', {style : 'position: absolute; bottom:
20px; left: 0; width: 100%; text-align: center;'}, [
JSL.create('input', {id : box_id_name + '_close',
type : 'button', value : 'Close Message', onclick : msg_close, style : 'margin: 0
auto; padding: 2px 20px; font-size: 11pt; font-family: Arial, Verdana, "Myriad
Pro"; font-weight: normal;'})
])
])
])
);
} else {
box.innerHTML += infoObject.text;
}
return false;
}
return str;
}
return elem;
}
function fixPlaySymbol() {
document.title = document.title.replace(rPlaySymbol, '');
}
JSL.waitFor({
selector : '#c4-player, #movie_player',
verifier : function (elem) {
elem = unwrap( elem[0] );
return typeof elem.stopVideo === 'function';
},
done : function () {
if (hasMainBeenRun === false) {
main();
}
}
});
}
// remove the player out of the document temporarily while other things are
being done,
// to reduce the time the player may be playing the video
parent.removeChild(player);
if (isHTML5) {
if (player.getPlaybackQuality() !== userOpts.quality) {
player.setPlaybackQuality(userOpts.quality);
}
if (!playIfPlaylist) {
if (userOpts.activationMode === 'buffer') {
player.pauseVideo();
} else if (userOpts.activationMode === 'none') {
player.stopVideo();
}
}
} else {
// copy 'ytplayer.config.args' into the flash vars
if (args) {
for (arg in args) {
val = args[arg];
if ( args.hasOwnProperty(arg) && isPrimitiveType(val) ) {
fv = setPref(fv, [ [ arg, encodeURIComponent(val) ] ]);
}
}
}
// ad removal
if (userOpts.hideAds) {
fv = fv.replace(new RegExp('(&|[&?])?(' + ads.join('|') +
')=[^&]*', 'g'), '');
/*
fv = setPref(fv,
ads.map(function (ad) {
return [ad, ''];
})
);
*/
}
// show the first time user message, then set it to never show again
if (GM_config.getValue('yt-autobuffer-autohd-first', 'yes') === 'yes') {
msg({
text : 'Welcome to "' + script_name + '".\n\n\n\n' +
'There is an options button below the video.\n\n\n\n' +
'The options screen will automatically open when you close this
message.',
title : '"' + script_name + '" Message',
onclose : function () { GM_config.open(); }
});
GM_config.setValue('yt-autobuffer-autohd-first', 'no');
}
}
// init GM_config
GM_config.init('"' + script_name + '" Options', {
activationMode : {
section : ['Main Options'],
label : 'Activation Mode',
type : 'select',
options : {
'buffer' : 'Auto Buffer (aka Auto Pause)',
'play' : 'Auto Play',
'none' : 'Stop Loading Immediately'
},
'default' : 'buffer'
},
autoHD : {
label : 'Auto HD',
type : 'select',
options : {
'default' : 'Automatic (default)',
'tiny' : '144p',
'small' : '240p',
'medium' : '360p',
'large' : '480p',
'hd720' : '720p (HD)',
'hd1080' : '1080p (HD)',
'hd1440' : '1440p (HD)',
'highres' : 'Original (highest)'
},
'default' : 'hd1080'
},
disableDash : {
label : 'Disable DASH Playback',
type : 'checkbox',
'default' : true,
title : '"DASH" loads the video in blocks/pieces; disrupts
autobuffering -- Note: Qualities are limited when disabled'
},
hideAds : {
label : 'Disable Ads',
type : 'checkbox',
'default' : true,
title : 'Should disable advertisements. AdBlock is better, though. Get
that instead'
},
hideAnnotations : {
label : 'Disable Annotations',
type : 'checkbox',
'default' : false
},
theme : {
section : ['Other Options'],
label : 'Player Color Scheme',
type : 'select',
options : {
'dark' : 'Dark Theme',
'light' : 'Light Theme'
},
'default' : 'dark'
},
volume : {
label : 'Set volume to: ',
type : 'select',
options : {
'1000' : 'Don\'t Change',
'0' : 'Off',
'5' : '5%',
'10' : '10%',
'20' : '20%',
'25' : '25% (quarter)',
'30' : '30%',
'40' : '40%',
'50' : '50% (half)',
'60' : '60%',
'70' : '70%',
'75' : '75% (three quarters',
'80' : '80%',
'90' : '90%',
'100' : '100% (full)',
},
title : 'What to set the volume to',
'default' : '1000'
},
autoplayplaylists : {
label : 'Autoplay on Playlists (override)',
type : 'checkbox',
'default' : false,
title : 'This will enable autoplay on playlists, regardless of the
"Activation Mode" option'
},
footer : {
label : 'Options Button In Footer',
type : 'checkbox',
'default' : false,
title : 'This will make the options button show at the bottom of the
page in the footer'
}
}, '' +
'body { ' +
'background-color: #DDDDDD !important; ' +
'color: #434343 !important; ' +
'font-family: Arial, Verdana, sans-serif !important; ' +
'}' +
'#config_header { ' +
'font-size: 16pt !important; ' +
'}' +
'.config_var { ' +
'margin-left: 20% !important; ' +
'margin-top: 20px !important; ' +
'}' +
'#header { ' +
'margin-bottom: 40px !important; ' +
'margin-top: 20px !important; ' +
'}' +
'.indent40 { ' +
'margin-left: 20% !important; ' +
'}' +
'.config_var * { ' +
'font-size: 10pt !important; ' +
'}' +
'.section_header_holder { ' +
'border-bottom: 1px solid #BBBBBB !important; ' +
'margin-top: 14px !important; ' +
'}' +
'.section_header { ' +
'background-color: #BEDBFF !important; ' +
'color: #434343 !important; ' +
'margin-left: 20% !important; ' +
'margin-top: 8px !important; ' +
'padding: 2px 200px !important; ' +
'text-decoration: none !important; ' +
'}' +
'.section_kids { ' +
'margin-bottom: 14px !important; ' +
'}' +
'.saveclose_buttons { ' +
'font-size: 14pt !important; ' +
'}' +
'#buttons_holder { ' +
'padding-right: 50px; ' +
'}' +
'', {
close : function () {
JSL('#c4-player, #movie_player').css('visibility', 'visible');
JSL('#lights_out').hide();
},
open : function () {
JSL('#c4-player, #movie_player').css('visibility', 'hidden');
JSL('#lights_out').show('block');
JSL('#GM_config').css('height', '80%').css('width', '80%');
}
});
// add a message listener for when the unsafeWindow function fires a message
window.addEventListener('message', function (msg) {
if (msg.data === 'YTAB__ready') {
main();
}
}, false);
// wait for an element that can hold the options button to load,
// then run our add button function
JSL.waitFor({
selector : '#watch7-headline, #gh-overviewtab div.c4-spotlight-module-
component, #footer-main',
done : addButton
});
}());