Large

YouTube Enhancer

By GIJoe Last update Dec 13, 2011 — Installed 1,194,611 times.

Add Friend Button in Video Mode - Suggestion

in
Subscribe to Add Friend Button in Video Mode - Suggestion 6 posts, 2 voices



Automatikkk User
FirefoxWindows

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 ?

 
GIJoe Script's Author
SeamonkeyMacintosh

The problem is: This feature is defined in the User Channel javascript, not in the watch page.
I think this feature is more suited to be in a dedicated script.

 
Automatikkk User
FirefoxWindows

hm, so what could you do?

Maybe you can write a small extra script, that could do this job?

 
Automatikkk User
FirefoxWindows

what is now about this ? Is it possible to do that or not ?

I think it is, so can you do it ?

 
GIJoe Script's Author
SeamonkeyMacintosh

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();

})();

 
Automatikkk User
FirefoxWindows

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 ;)

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel