Add Friend Button in Video Mode - Suggestion
![]() ![]() |
Hi again I have a good Idea that isnt in ANY youtube script yet, but its a very cool feature! It would make it alot easier to add your friends in youtube! Add Friend (Button) together with subscribe in normal watching Video Mode! Like in this Picture I made: or in diff color
http://img4.imageshack.us/gal.php?g=youtubeaddf... Abbonieren = Subscribe (german youtube) how do you GIJoe and Reader of this Topic think about it ? |
![]() ![]() |
The problem is: This feature is defined in the User Channel javascript, not in the watch page.
|
![]() ![]() |
hm, so what could you do? Maybe you can write a small extra script, that could do this job? |
![]() ![]() |
what is now about this ? Is it possible to do that or not ? I think it is, so can you do it ? |
![]() ![]() |
Here a start: // ==UserScript==
// @name Youtube Add Friend Button
// @namespace http://userscripts.org
// @description Youtube Add Friend Button
// @include http://www.youtube.com/*
// ==/UserScript==
(function() {
//***************************************************
var innerscript = function() {//Start of innerscript
add_friend=function(name) {
alert(name);
}
}//******************************//End of innerscript
//***************************************************
function AddInnerScript(script) {
var scriptElem=document.createElement('script');
scriptElem.setAttribute('type','text/javascript');
scriptElem.textContent="("+script+")();";
document.body.appendChild(scriptElem);
}
function Add_Script() {
AddInnerScript(innerscript.toString());
}
function Add_Button() {
var user=document.evaluate('//a[contains(@class,"contributor")]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if(!user) { return; }
var username=user.textContent;
var Elem=document.evaluate('//div[@id="subscribeDiv"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if(!Elem) { return; }
var DivElem=document.createElement('div');
DivElem.setAttribute('style','text-align:right; margin-top:2px;');
var linkElem=document.createElement('a');
linkElem.setAttribute('class','yt-button yt-button-urgent');
linkElem.setAttribute('href','#');
linkElem.setAttribute('onclick',"add_friend('"+username+"'); return false;");
spanElem=document.createElement('span');
spanElem.textContent='Add Friend';
linkElem.appendChild(spanElem);
DivElem.appendChild(linkElem);
Elem.parentNode.appendChild(DivElem);
}
Add_Script();
Add_Button();
})();
|
![]() ![]() |
Good Start! Thanks! But it doesn't seem to work. Could you finish it? pls :) Iam not a programmer/scripter. you are the pro here ;) |




