Advertisement
Guest User

Fix Youtube user parsing for whitelisting script

a guest
May 1st, 2016
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var exposeUserInURL = function() {
  2.     'use strict';
  3.  
  4.     // To fix issue with user name, parse it from a different query, so
  5.     // the following method works currently. Variable channelId will thus
  6.     // contain the Youtube user name.
  7.     // Replace lines from "var link = document.querySelector ..." to
  8.     // "var channelId = ..." with the following code (within "// ---"):
  9.     // ---
  10.     var link = document.querySelector('[id="watch7-user-header"] a[href^="/user/"]');
  11.     if ( link === null ) {
  12.        return;
  13.     }
  14.     var linkHref = link.getAttribute('href');
  15.     var linkmatch = linkHref.match(/\/user\/(.+)/);
  16.     if (linkmatch === null)
  17.         return;
  18.     var channelId = linkmatch[1];
  19.     // ---
  20.  
  21.     // Code below need not be changed
  22.     var newArg = channelId !== '' ? 'user=' + encodeURIComponent(channelId) : '';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement