ptrharmonic / poets.org but public domain only

// ==UserScript==
// @name     poets.org but public domain only
// @version  1.1
// @grant    none
// @include https://poets.org/poems
// @include https://poets.org/poems?*
// @license MIT
// @copyright 2021, ptrharmonic (https://openuserjs.org/users/ptrharmonic)
// @updateURL https://openuserjs.org/meta/ptrharmonic/poets.org_but_public_domain_only.meta.js
// @downloadURL https://openuserjs.org/install/ptrharmonic/poets.org_but_public_domain_only.user.js
// ==/UserScript==

var counter = 0;
var observable;
var observer;

const PUBLIC_DOMAIN_CUTOFF = (new Date()).getFullYear() - 96;

function filter() {
  let t = document.getElementById("poems");
  let tbody = t.children[1];
  for (let i = 0; i < tbody.children.length; i++) {
    let year = tbody.children[i].children[2].innerText;
    if (year.length > 0) {
      if (parseInt(year) >= PUBLIC_DOMAIN_CUTOFF) {
        tbody.children[i].style.display = "none";
      }
      else {
        tbody.children[i].style.display = null;
      }
    }
    else {
      tbody.children[i].style.display = null;
    }
  }
}

function observe() {
  let t = document.getElementById("poems");
  var tbody = t.children[1];
  let fun;
  if (counter < 2) {
    observable = t.parentElement.parentElement.parentElement;
    fun = observeCaller;
    counter++;
  }
  else {
    observable = t;
    fun = filter;
  }
  if (observer) {
    observer.disconnect();
  }

  observer = new MutationObserver(function (mutations) {
    fun();
  });
  observer.observe(observable, {
    childList: true,
    subtree: true,
    characterData: true
  });
}

function observeCaller() {
  observe();
}

observe();