Embed Tweak

Modifies Youtube embed videos, Forces all videos to a larger size (640x385) or (1024x576), With options for: Video Size, Https, Autohide, Theme, Hide Annotations and Hide Related. Latest version based on https://gf.qytechs.cn/scripts/829-restore-youtube-embed-defaults

目前为 2014-08-13 提交的版本。查看 最新版本

// ==UserScript==
// @name        Embed Tweak
// @namespace	embedtweak
// @grant       none
// @description	Modifies Youtube embed videos, Forces all videos to a larger size (640x385) or (1024x576), With options for: Video Size, Https, Autohide, Theme, Hide Annotations and Hide Related. Latest version based on https://gf.qytechs.cn/scripts/829-restore-youtube-embed-defaults
// @version	13 August 2014 (1.3)
// @include	http*
// @exclude	*liveleak.com*
// @exclude	*.youtube.com/*
// ==/UserScript==   
//
// Set variables below
//
// Set Video Size, large or medium. Large (1024x576) medium (640x385)
var videosize = 'medium';
// 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'
// theme, options: light or default
var ytheme = 'light';
// 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 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 = document.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_node.indexOf('youtube-nocookie.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 (annotation == 0) {
      ivid = 'iv_load_policy=3&';
    }
    if (related == 0) {
      relatedid = 'rel=0&';
    }
    if (autohide == 1) {
      ahid = 'autohide=1&';
    }
    video_url = protid + 'www.youtube.com/embed/' + video_id + '?' + ythemeid + ivid + relatedid + ahid;
  }
  video_link = document.createElement('iframe');
  video_link.setAttribute('src', video_url);
  // Set the width, if present
  if (videosize == 'large') {
    video_link.width = '1024';
    video_link.height = '576';
  }
  if (videosize == 'medium') {
    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或关注我们的公众号极客氢云获取最新地址