Add Drive to YouTube Header

Adds Drive link to YouTube header menu

  1. // ==UserScript==
  2. // @name Add Drive to YouTube Header
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Adds Drive link to YouTube header menu
  6. // @author Your Name
  7. // @match https://vanced-youtube.neocities.org/2011/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Create the new <li> element
  15. var driveNode = document.createElement('li');
  16. driveNode.className = 'gbt';
  17. driveNode.innerHTML = '<a class="gbzt" id="gb_23" onclick="gbar.qs(this);gbar.logger.il(1,{t:23})" href="http://mail.google.com/mail/?hl=en&amp;tab=wm"><span class="gbtb2"></span><span class="gbts">Drive</span></a>';
  18.  
  19. // Find the Gmail <li> element
  20. var gmailNode = document.querySelector('li.gbt a.gbzt#gb_23[href="http://mail.google.com/mail/?hl=en&tab=wm"]');
  21.  
  22. // Insert the new node after the Gmail node
  23. if (gmailNode) {
  24. var parent = gmailNode.parentNode.parentNode;
  25. parent.insertBefore(driveNode, parent.children[parent.children.length - 1].nextSibling);
  26. }
  27. })();