#StackBounty: #youtube #notifications Is it possible to get notifications for new comments on a YouTube video?

Bounty: 50

Suppose that there is a video on YouTube which is not on my channel, but published by somebody else.

Is there some way in which I can subscribe to get the notifications about new comments on that particular video?


One use case I can imagine: Many teachers now use YouTube to publish videos with their lectures. And both the students and the teacher might be interested to see new comments. (And in many cases the YouTube channel is not the channel created by the teacher – it might be a channel of the school/department/university. So it’s a bit different from setting up notifications about new activity on my own videos.)


Note. I have seen that there is already this question: How to subscribe to YouTube comments? From the formulation of the question it seems that this question might be considered a duplicate of that one. However, the accepted answer answers the question as if the word subscribe was meant as pay for a subscription. (I am not sure whether this is what the asker intended, but that is the answer they’ve accepted.) Therefore I opted for a new question rather than a bounty on the old one – since to some extent, the offered bounty would be asking for something different from the already accepted answer.


Get this bounty!!!

#StackBounty: #javascript #youtube #youtube-api Trying to remove delay

Bounty: 50

I hope someone can help with this.

I’m not looking for an answer from a reputable source, I clicked on the wrong option. I never used bounty before.

If you are able to solve the bounty you will get the 50.

Sorry for the confusion.

All I am doing here is trying to remove the delay.

The YouTube video (aka iframe) doesn’t get created until after createPlayer(args) is called on line 140. Since it is part of the click handler that means it gets created after the click. There is a delay happening as the video is fetched and loaded.

enter image description here

How would this be fixed in the code so that there is not a delay?

To Reproduce: Click Run, then the play image, do it repeatedly to see the delay.

After clicking the the play image, it doesn’t go straight to the video, there’s a delay that occurs that can be clearly seen.

How would I remove that delay?

Click Run, not update to test jsitor code: https://jsitor.com/W0Iu1msGS

You can make edits to the jsfiddle link: https://jsfiddle.net/w2Lphczf/

The delay appears in both.

    const manageCover = (function makeManageCover() {
        const config = {};
    
        function show(el) {
            el.classList.remove("hide");
        }
    
        function hide(el) {
            el.classList.add("hide");
        }
    
        function hideAll(elements) {
            elements.forEach(hide);
        }
    
        function showCovers(playButton) {
            const cover = playButton.parentElement;
            cover.classList.add("active");
            show(cover);
        }
    
        function coverClickHandler(evt) {
            hideAll(config.containers);
            const cover = evt.currentTarget;
            showCovers(cover);
        }
    
        function addClickToButtons(playButtons) {
            playButtons.forEach(function addEventHandler(playButton) {
                playButton.addEventListener("click", coverClickHandler);
            });
        }
    
        function addCoverHandler(coverSelector, handler) {
            const cover = document.querySelector(coverSelector);
            cover.addEventListener("click", handler);
        }
    
        function init(selectors) {
            config.containers = document.querySelectorAll(selectors.container);
            const playButtons = document.querySelectorAll(selectors.playButton);
            addClickToButtons(playButtons);
        }
    
        return {
            addCoverHandler,
            init,
            show
        };
    }());
    
    const manageCover = (function makeManageCover() {
  const config = {};

  function show(el) {
    el.classList.remove("hide");
  }

  function hide(el) {
    el.classList.add("hide");
  }

  function hideAll(elements) {
    elements.forEach(hide);
  }

  function showCovers(playButton) {
    const cover = playButton.parentElement;
    cover.classList.add("active");
    show(cover);
  }

  function coverClickHandler(evt) {
    hideAll(config.containers);
    const cover = evt.currentTarget;
    showCovers(cover);
  }

  function addClickToButtons(playButtons) {
    playButtons.forEach(function addEventHandler(playButton) {
      playButton.addEventListener("click", coverClickHandler);
    });
  }

  function addCoverHandler(coverSelector, handler) {
    const cover = document.querySelector(coverSelector);
    cover.addEventListener("click", handler);
  }

  function init(selectors) {
    config.containers = document.querySelectorAll(selectors.container);
    const playButtons = document.querySelectorAll(selectors.playButton);
    addClickToButtons(playButtons);
  }

  return {
    addCoverHandler,
    init,
    show
  };
}());

const videoPlayer = (function makeVideoPlayer() {
  const players = [];
  let player = null;

  const tag = document.createElement("script");
  tag.src = "https://www.youtube.com/player_api";
  const firstScriptTag = document.getElementsByTagName("script")[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  function onPlayerReady(event) {
    player = event.target;
    player.setVolume(100);
    player.playVideo();
  }

  function addPlayer(video, settings) {
    const defaults = {
      playerOptions: {
        events: {
          "onReady": onPlayerReady
        },
        host: "https://www.youtube-nocookie.com",
        videoId: video.dataset.id
      }
    };
    const playerOptions = Object.assign(defaults.playerOptions, settings);
    players.push(new YT.Player(video, playerOptions));
  }

  return {
    addPlayer

  };
}());

const managePlayer = (function makeManagePlayer() {
  const defaults = {
    playerOptions: {
      height: 600,
      playerVars: {
        controls: 1,
        disablekb: 1,
        enablejsapi: 1,
        fs: 0,
        iv_load_policy: 3,
        rel: 0
      },
      width: 360
    }
  };

  function show(el) {
    el.classList.remove("hide");
  }

  function createPlayerOptions(settings) {
    function paramInOptions(opts, param) {
      if (settings[param] !== undefined) {
        opts[param] = settings[param];
        delete settings[param];
      }
      return opts;
    }

    const optionParams = ["width", "height", "videoid", "host"];
    const defaultOptions = defaults.playerOptions;
    const preferred = optionParams.reduce(paramInOptions, {});
    const playerOptions = Object.assign({}, defaultOptions, preferred);
    // settings should now only consist of playerVars
    const defaultPlayerVars = defaultOptions.playerVars;
    const playerVars = Object.assign({}, defaultPlayerVars, settings);
    playerOptions.playerVars = playerVars;
    return playerOptions;
  }

  function createPlayer(videoWrapper, settings = {}) {
    const video = videoWrapper.querySelector(".video");
    const playerOptions = createPlayerOptions(settings);
    return videoPlayer.addPlayer(video, playerOptions);
  }

  function createCoverClickHandler(playerSettings) {
    return function coverClickHandler(evt) {
      const cover = evt.currentTarget;
      const wrapper = cover.nextElementSibling;
      show(wrapper);
      const player = createPlayer(wrapper, playerSettings);
      wrapper.player = player;
    };
  }

  function addPlayer(coverSelector, playerSettings) {
    const clickHandler = createCoverClickHandler(playerSettings);
    manageCover.addCoverHandler(coverSelector, clickHandler);
  }

  function init(playerOptions) {
    Object.assign(defaults.playerOptions, playerOptions);
  }

  return {
    add: addPlayer,
    init
  };
}());

function onYouTubeIframeAPIReady() {
  managePlayer.add("svg.playa", {
    height: 207,
    width: 277
  });
  managePlayer.add("svg.playb", {
    height: 207,
    width: 277
  });
  manageCover.init({
    container: ".container",
    playButton: ".thePlay"
  });
}


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!

#StackBounty: #youtube #ads Why don't I see ads on YouTube with my Google account?

Bounty: 50

I have already seen this similar question but my problem is not exactly same.

I noticed that with my main Google account, I do not see any ads on YouTube (although I don’t like seeing them, I am just curious) , while if I switch to incognito, ads do show up.

When I switched my Google account with another one, again ads showed up! So is it something to do with my Google account?

I use Google Chrome and I don’t have any extensions installed at the moment.


Get this bounty!!!