Advertisement
Calgon

YouTube video hiding tool (hides title/other info)

Apr 6th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.94 KB | None | 0 0
  1. <!DOCTYPE html>  
  2.     <html lang="en">  
  3.     <head>
  4.         <meta charset="utf-8" />  
  5.         <meta name="author" content="Frederick Wright">
  6.         <title>Video Hider</title>  
  7.         <!-- Just for the ready handler -->
  8.         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  9.         <script type="text/javascript">
  10.             /* I take no credit for the querystring function */
  11.             var queryStringValue = window.location.search;
  12.  
  13.             location.querystring = (function() {
  14.                 // The return is a collection of key/value pairs
  15.                 var queryStringDictionary = {};
  16.                 // Gets the query string, starts with '?'
  17.                 var querystring = decodeURI(location.search);
  18.              
  19.                 // document.location.search is empty if no query string
  20.              
  21.                 if (!querystring) {
  22.                     return {};
  23.                 }
  24.              
  25.                 // Remove the '?' via substring(1)
  26.                 querystring = querystring.substring(1);
  27.              
  28.                 // '&' seperates key/value pairs
  29.                 var pairs = querystring.split("&");
  30.              
  31.                 // Load the key/values of the return collection
  32.                 for (var i = 0; i < pairs.length; i++) {
  33.                     var keyValuePair = pairs[i].split("=");
  34.                     queryStringDictionary[keyValuePair[0]]
  35.                             = keyValuePair[1];
  36.                 }
  37.              
  38.                 // toString() returns the key/value pairs concatenated
  39.                 queryStringDictionary.toString = function() {
  40.              
  41.                     if (queryStringDictionary.length == 0) {
  42.                         return "";
  43.                     }
  44.              
  45.                     var toString = "?";
  46.              
  47.                     for (var key in queryStringDictionary) {
  48.                         toString += key + "=" +
  49.                             queryStringDictionary[key];
  50.                     }
  51.                     return toString;
  52.                 };
  53.                 // Return the key/value dictionary
  54.                 return queryStringDictionary;
  55.             })();
  56.            
  57.             function generateVideo() {
  58.                 var videoURL = "http://www.youtube.com/v/" + location.querystring["video_id"] + "&feature&autoplay=1&rel=0&fs=0&showinfo=0";
  59.                 var videoWatchLink = "https://www.youtube.com/watch?v=" + location.querystring["video_id"];
  60.                 document.getElementById('video-container').style.display = 'block';
  61.                 document.getElementById('param1').value = videoURL;
  62.                 document.getElementById('param2').src = videoURL;
  63.                 document.getElementById('watch_on_yt').href = videoWatchLink;
  64.                 document.getElementById('video-container').style.display = 'block';
  65.             }
  66.            
  67.             $(document).ready(function() {
  68.                 if(location.querystring["video_id"] != undefined) {
  69.                     generateVideo();
  70.                 }
  71.             });
  72.            
  73.             function createLink() {
  74.                 var videoID = document.getElementById("video_url").value;
  75.                 document.location = "?video_id=" + videoID;
  76.             }
  77.         </script>
  78.         <style type="text/css">
  79.         body {
  80.             font-family: Arial;
  81.             font-size: 14px;
  82.             text-align: center;
  83.         }
  84.         #video-container {
  85.             height: 315px;
  86.             width: 560px;
  87.             margin: auto;
  88.             display: none;
  89.         }
  90.         form {
  91.             border-style: solid;
  92.             border-width: 1px;
  93.             border-color: black;
  94.             width: 560px;
  95.             margin: auto;
  96.             padding: 12px;
  97.             margin-bottom: 12px;
  98.         }
  99.         a {
  100.             text-decoration: none;
  101.             color: #1A1A1A;
  102.             font-weight: bold;
  103.         }
  104.         </style>
  105.         </head>  
  106.     <body>
  107.        
  108.         <form method="get" onsubmit="return false;">
  109.             YouTube Video ID: <input type="text" name="video_url" id="video_url" /> <br /><br />
  110.             <input type="submit" name="submit" value="Create Link" onclick="createLink();" />
  111.         </form>
  112.        
  113.         <div id="video-container">
  114.             <object width= "560" height="315"><param name="movie" value="http://www.youtube.com/v/vM1pvax-OTk&autoplay=1&showinfo=0&hd=1" id="param1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed id="param2" src="http://www.youtube.com/v/vM1pvax-OTk&autoplay=1&showinfo=0&hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="315" allowscriptaccess="always"></embed></object> <br /><br />
  115.            
  116.             <a href="" id="watch_on_yt" target="_new">Watch on YouTube</a>
  117.         </div>
  118.        
  119.         <br /><br /><br />
  120.        
  121.         <i>NOTE: Some videos may not work as they do not support embedding.</i>
  122.        
  123.     </body>
  124. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement