Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name GPForums Youtube Autoplay
- // @namespace awt
- // @description WIP - To autoplay embedded youtube clips one at a time
- // @include http://www.gpforums.co.nz/*
- // ==/UserScript==
- document.body.style.background = "#636363"; // Just to make it obvious script is running or not.
- //alert("Youtube Embedded List Autoplay Script Started");
- var nodeList = document.getElementsByTagName("embed"); // Get all embedded objects
- var objects = new Array();
- // Convert NodeList "nodeList" to an Array of Nodes "objects"
- for (i=0;i<nodeList.length;i++){
- objects.push(nodeList[i]);
- }
- // Ensure embedded objects are YouTube, and remove duplicates.
- i = 0;
- do {
- var stringA;
- var stringB;
- // Get source of the embedded object
- var attributes = objects[i].attributes;
- var source = attributes.getNamedItem("src");
- // Checks that embedded file is youtube. **Don't know if this works, haven't come across any non-youtube embeds.**
- if (source == -1|| source.nodeValue.indexOf("http://www.youtube.com/v/") == -1) {
- alert("Non-YouTube embedded object found");
- // ... and will need to write something else here, if this situation ever arises.
- }
- // Ensure each equivalent (same source) object is only present once in the array.
- stringA = source.nodeValue;
- j = 0;
- do {
- var compAttributes = objects[j].attributes;
- var compSource = compAttributes.getNamedItem("src");
- stringB = compSource.nodeValue;
- if (stringA == stringB && !(i==j) ){ // If same source but not the same index
- objects.splice(j,1);
- j--; // array length changed by splice, so need to re-check this index
- }
- j++;
- } while (j < objects.length);
- i++;
- } while (i < objects.length);
- alert(objects.length + " Youtube clips lined up.");
- // *** All code below here is things i'm not sure about *****
- // Add the <object.. (parent node of <embed..) to the objs array
- // Not sure which
- var objs = new Array();
- for(var k = 0; k < objects.length; k++){
- var parent = objects[k].parentNode;
- objs.push(parent);
- }
- // The big FFFFUUUUU. This is supposed to be called automatically when the embedded player(s?) are ready to accept commands.
- function onYouTubePlayerReady(playerid){
- alert("TYPR!!!!!!");
- }
Advertisement
Add Comment
Please, Sign In to add comment