您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Modifies Youtube embed videos, Forces all videos to a larger size (640x385) or (1024x576), With options for: Video Size, HD Playback, Https, Autohide, Theme, Hide Annotations and Hide Related.
当前为
// ==UserScript== // @name Youtube Embed Tweak // @namespace embedtweak // @grant none // @icon http://i.imgur.com/JyEgdDl.png // @description Modifies Youtube embed videos, Forces all videos to a larger size (640x385) or (1024x576), With options for: Video Size, HD Playback, Https, Autohide, Theme, Hide Annotations and Hide Related. // @version 1.52 (04 March 2015) // @include http* // @exclude *liveleak.com* // @exclude *.youtube.com/* // ==/UserScript== // // Set variables below // // Set Video Size, with a 16:9 preset, Large (1024x576) medium (720x405) small (640x385) or Set size in percentage, for a video size as a percantage of the container size. var videosize = 'medium'; // or //var videosize = '50%'; // nochangeurl must be set to no for player settings to work. yes = default url and no = modified url, size is always modified. var nochangeurl = 'no'; // hd = 0 or 1 or 2. 0 = default, 1 = 720p , 2 = 1080p. if available. var hd = 1; // theme, options: light or dark var ytheme = 'dark'; // color, options: red or white var ycolor = 'white'; // Set annotation = 0 or 1, 0 disables annotations var annotation = 0; // Show Related videos at end of playback, option: 1 or 0, var related = 0; // Force https option, 1 or 0, 1 enables https var ssl = 1; // Set autohide = 0 or 1, 1 enables auto hide of player controls. (0 is default behaviour) var autohide = 1; // // // // //////////////////////////////////////////////// // No need to modify anything past this point // //////////////////////////////////////////////// var ob = new MutationObserver(function(mutations){ for (var m, i=0; i<mutations.length && (m=mutations[i]); i++) for (var nodes=m.addedNodes, n, j=0; j<nodes.length && (n=nodes[j]); j++) // code thanks to wOxxOm if (n.nodeType == Node.ELEMENT_NODE) embedTweak(n); }); ob.observe(document, {subtree:true, childList:true}); if (document.body) embedTweak(document.body); function embedTweak(node) { var i,j,k,index; var video_id,video_url,video_link; var risky_elements,risky_attributes,risky_node; var risky_tags = [ 'object', 'embed', 'iframe' ]; var bad_elements = [ ]; var bad_ids = [ ]; for (i = 0; i < risky_tags.length; i++) { risky_elements = node.getElementsByTagName(risky_tags[i]); for (j = 0; j < risky_elements.length; j++) { index = 0; risky_attributes = risky_elements[j].attributes; for (k = 0; k < risky_attributes.length; k++) { risky_node = risky_attributes[k].nodeValue; if (risky_node.indexOf('youtube.com') >= 0) { risky_elements[j].style.display = 'none'; if (risky_node.indexOf('/v/') >= 0) { index = risky_node.indexOf('/v/') + 3; } else if (risky_node.indexOf('?v=') >= 0) { index = risky_node.indexOf('?v=') + 3; } else if (risky_node.indexOf('/embed/') >= 0) { index = risky_node.indexOf('/embed/') + 7; } if (index > 0) { video_id = risky_node.substring(index, index + 11); bad_elements.push(risky_elements[j]); bad_ids.push(video_id); } break; } } } } for (i = 0; i < bad_ids.length; i++) { video_id = bad_ids[i]; if (nochangeurl == 'yes') { video_url = 'http://www.youtube.com/embed/' + video_id; } else { if (ssl == 1) { protid = 'https://' } if (ssl == 0) { protid = 'http://' } if (ytheme == 'light') { ythemeid = 'theme=light&'; } if (ytheme == 'dark') { ythemeid = 'theme=dark&'; } if (annotation == 0) { ivid = 'iv_load_policy=3&'; } if (annotation == 1) { ivid = 'iv_load_policy=1&'; } if (related == 0) { relatedid = 'rel=0&'; } if (related == 1) { relatedid = 'rel=1&'; } if (autohide == 1) { ahid = 'autohide=1&'; } if (autohide == 0) { ahid = 'autohide=0&'; } if (ycolor == 'red') { ycolorid = 'color=red&'; } if (ycolor == 'white') { ycolorid = 'color=white&'; } if (hd == 0) { hdid = 'vq=default&'; } if (hd == 1) { hdid = 'vq=hd720&'; } if (hd == 2) { hdid = 'vq=hd1080&'; } video_url = protid + 'www.youtube.com/embed/' + video_id + '?' + ythemeid + ycolorid + ivid + relatedid + ahid + hdid; } video_link = document.createElement('iframe'); video_link.setAttribute('src', video_url); if (vsm = videosize.match(/^\s*(\d+)%\s*$/)) { // percentage size code thanks to wOxxOm var parent = bad_elements[i].parentNode; while (parent) { available_width = parent.offsetWidth || parent.clientWidth; if (available_width > 0) { video_link.width = available_width * vsm[1] / 100; video_link.height = Math.floor(video_link.width / 16 * 9); break; } parent = parent.parentNode; } } if (videosize == 'large') { video_link.width = '1024'; video_link.height = '576'; } if (videosize == 'medium') { video_link.width = '720'; video_link.height = '405'; } if (videosize == 'small') { video_link.width = '640'; video_link.height = '385'; } video_link.setAttribute('frameborder', '0'); video_link.setAttribute('allowfullscreen', '1'); bad_elements[i].parentNode.replaceChild(video_link, bad_elements[i]); } }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址