Page 5 of 5

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Thu Aug 21, 2014 8:42 am
by Gingerbread Man
Getting back to the feature request that this thread is about, I didn't see a relevant issue report, so I filed one.
https://issues.adblockplus.org/ticket/1254RSS feed

The Binary Son wrote:I just tested a playlist, and the "&user=" thing popped up for all of them.

Allow the playlist to advance automatically. Right-click the Back button. You'll see the current video at the top of the list (the URL with &user=), and then the same video again below that (the original URL before the script modified it).
The Binary Son wrote:Only weird things I noticed in the links of videos in playlists is that with the exception of the first video of the playlist (assuming you hit play all), all the other videos' links will have "&index=" and then the number that video is in the playlist, somewhere in the link. And it seems to randomly appear in one of either 2 spots: right before the "&user" part or right before the "&list=" part.

Anything that's not &user= is added by the site. The script always adds that at the end of the URL, but I guess in some cases the script does its job first, and in others, the site's script modifies the URL first. I don't think there's anything I can do about it. Since I can't think of a reason to need URL parameters in a particular order, I don't think it matters anyway.
The Binary Son wrote:The other weird thing I noticed, just looking at my own personal playlists in my own account of others' videos, if I just hit "play all," the "user" listed in the first video will be me, the creator of the playlist.

I'll look into it. It'll be another day or two before I have anything to report.

Though I have to wonder if a user script is even necessary for most people. Nowadays the channel listing pages link to videos that include a playlist of all that user's videos. So you can create a whitelist filter based on that, e.g.
Code: Select all
@@||youtube.com/*&list=UUh9v402vYSWOzHW9KBuLPng$document

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Thu Aug 21, 2014 4:39 pm
by Gingerbread Man
I posted version 1.3 of the script.
https://greasyfork.org/scripts/4168-youtube-whitelist-channels-in-adblock-plus

It should work on all video pages, without exception. Another notable difference is that Firefox users can right-click the user name below a video to show the relevant whitelist filter. I figured novice users might find that useful.

You're welcome 8)

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Tue Aug 26, 2014 2:03 pm
by The Binary Son
Gingerbread Man wrote:I posted version 1.3 of the script.
https://greasyfork.org/scripts/4168-youtube-whitelist-channels-in-adblock-plus

It should work on all video pages, without exception. Another notable difference is that Firefox users can right-click the user name below a video to show the relevant whitelist filter. I figured novice users might find that useful.

You're welcome 8)


http://sonniematherphotography.com.au/w ... o1_250.gif


Seriously, thank you. This. Is. Awesome.

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Sat Sep 13, 2014 3:44 pm
by lewisje
This is exactly what AdBlock (Michael Gundlach's effort) does when you check the option to whitelist individual YouTube channels, and the annoying thing there is that it doesn't tell you that it will cause every YouTube video to refresh; it took me an hour to figure out that that's what was causing it. (I have since moved on to µBlock, and both of these are for Chromium-based browsers.)

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Tue Sep 16, 2014 4:40 am
by phanhan
Follow me, I don't really get what yall are doing with those scripts. I'm just an average user of adblock.
But I came here to support this! I'd love to be able to support deserving youtube channels more.
Again, this coming from an average user.

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Fri Nov 28, 2014 7:00 am
by thematrix185
Script is only working in certain instances for me.

If I follow a link to a youtube video the script works and adds the "&user=" parameter. However if I navigate to a video while on Youtube, either through the main page, subscription page or clicking on video listed on the right hand side the parameter does not appear. If I refresh the page manually, the parameter will then appear in the url bar.

I created a similar script myself and had the same problem. In my script I added an alert just to see what happens. The alert box did not pop up when the page was loaded, instead it would only appear if I did a manual refresh of the page, at which point it would disappear quickly and the refreshed page would load with the parameter appearing in the URL bar and the alert popping up correctly.

I have been testing this on Firefox 33.1.1 with no other extensions enabled except for Greasemonkey. I get the same issue whether I am logged in to Youtube or not. It appears that on these Youtube pages nothing in the Greasemonkey script is running, but I can't understand why.


I can install another script Youtube Links (https://greasyfork.org/en/scripts/5566-youtube-links) and this works on all videos regardless of how they are accessed. A very confusing problem.

Any ideas would be most appreciated.

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Sat Nov 29, 2014 8:16 am
by Gingerbread Man

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Mon Mar 09, 2015 6:05 pm
by andrybak-tmp
Gingerbread Man wrote:↑ Update to script version 1.4.
https://greasyfork.org/en/scripts/4168-youtube-whitelist-channels-in-adblock-plus


Something in my addons makes it so that item doesn't appear context menu. In the code: near comment "// Add the context menu to the user name below the video // Only works in Firefox".

Addon https://addons.mozilla.org/en-US/firefo ... enu-editor is the culprit.

Also, it would be great if this script could add the filter automatically, without needing to copy it from the input field and insert it into Adblock plus filter preferences.

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Thu Mar 12, 2015 7:40 am
by Gingerbread Man
andrybak-tmp wrote:Addon https://addons.mozilla.org/en-US/firefo ... enu-editor is the culprit.

I can't do anything about broken add-ons. Menu Editor has been abandoned (last updated 2011-03-08). You can replace it with Menu Wizard and see if that one works any better.
andrybak-tmp wrote:Also, it would be great if this script could add the filter automatically

User scripts can only affect web pages.

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Tue Jan 26, 2016 3:53 pm
by Compuitguy
@Gingerbread Man

Proposed Patch: Avoid refresh

https://greasyfork.org/en/forum/discuss ... id-refresh

Re: Suggestion: Enabling YouTube Ads Depending on Channel

PostPosted: Sun Aug 06, 2017 9:32 pm
by drm31415
I made some changes to allow filtering on subscription status or notification level

Code: Select all
// ==UserScript==
// @name        YouTube - whitelist channels in Adblock Plus
// @namespace   
// @author      drm31415
// @credits     Eyeo GmbH, Gantt, rimmington,Gingerbread Man
// @description Helps whitelist YouTube channels in Adblock Plus
// @include     http://*.youtube.com/*
// @include     https://*.youtube.com/*
// @version     1.7
// @grant       none
// @license     http://creativecommons.org/licenses/by-sa/4.0/
// @supportURL  viewtopic.php?f=1&t=23697
// ==/UserScript==

var updateHref = function (url) {
   window.history.replaceState(history.state, "", url);
};

var activate = function () {
   if (location.href.search("&user=") != -1) return;
   
   var AppendFields="";
   var uo = document.querySelector('#watch7-content link[href*="/user/"]');
   var uv = document.querySelector('.yt-user-info > a[href*="/channel/"]');
   var channelName = (uo && uo.href.slice(uo.href.lastIndexOf("/")+1)) || (uv && uv.textContent);

   if(channelName){
      var SubbedStatus="";
      var NotificationLevel="";

      AppendFields+="&user="+channelName;
      
      if(document.querySelector('.yt-uix-button-subscribe-branded')){
         SubbedStatus="No";
      }
      else if(document.querySelector('.yt-uix-button-subscribed-branded')){
         SubbedStatus="Yes";
      }
      if(SubbedStatus!=""){
         AppendFields+="&SubbedStatus="+SubbedStatus;
      }

      if(document.querySelector('.yt-uix-subscription-notifications-highlights')){
         NotificationLevel="highlights";
      }
      else if(document.querySelector('.yt-uix-subscription-notifications-all')){
         NotificationLevel="all";
      }
      if(NotificationLevel!=""){
         AppendFields+="&NotificationLevel="+NotificationLevel;
      }
   }
   
   if (AppendFields!="") {
      updateHref(location.href+AppendFields);
   }
}

// For static pages
activate();

// For dynamic content changes, like when clicking a video on the main page.
// This bit is based on Gantt's excellent Download YouTube Videos As MP4 script:
// https://github.com/gantt/downloadyoutube
var observer = new MutationObserver(function(mutations) {
   mutations.forEach(function(mutation) {
      if (mutation.addedNodes !== null) {
         for (i = 0; i < mutation.addedNodes.length; i++) {
            if (mutation.addedNodes[i].id == "watch7-main-container") {
               activate();
               break;
            }
         }
      }
   });
});
observer.observe(document.body, {childList: true, subtree: true});



//@@||youtube.com/*&SubbedStatus=Yes$document