nharward / nhl.tv remove game center widget

// ==UserScript==
// @name         nhl.tv remove game center widget
// @namespace    https://openuserjs.org/meta/nharward/nhl.tv
// @version      0.2
// @description  Removes the buggy and often score-spoiling game center widget
// @author       Nathaniel Harward
// @match        https://www.nhl.com/tv/*
// @grant        none
// @license MIT
// @copyright 2020, nharward (https://openuserjs.org/users/nharward)
// ==/UserScript==
// ==OpenUserJS==
// @author nharward
// ==/OpenUserJS==

function handleNode(node) {
  if (node.id === "gamecenter-widget") {
    node.parentNode.removeChild(node);
    console.log("Removed game center widget");
  }
}

function mutationCallback(mutationsList, observer) {
  mutationsList.forEach((mutationRecord) => {
    if (mutationRecord.addedNodes) {
      mutationRecord.addedNodes.forEach(handleNode);
    }
  });
}

(function () {
  'use strict';
  new MutationObserver(mutationCallback).observe(document.body, {
    childList: true,
    subtree: true
  });
})();