HankLloydright / TMC hide read threads and always go to Last Unread Post

// ==UserScript==
// @name         TMC hide read threads and always go to Last Unread Post
// @namespace    http://tampermonkey.net/
// @version      1.03.09a
// @description  For the latest TMC Update 2021, hides all "read" threads in the Watched Threads view. Opens all threads in a new tab. Also for any thread over 30 days old, clicking the thread title link reverts to the first post in the thread instead of 'last unread post'.  But we never know which threads expired and which ones didn't.  So this script makes every thread title to to the /unread link, regardless of thread age.
// @author       HankLloydRight
// @include      https://teslamotorsclub.com/tmc/watched/threads*
// @include      https://teslamotorsclub.com/tmc/whats-new/posts/*
// @include      https://teslamotorsclub.com/tmc/account/alerts/*
// @grant        none
// @license      MIT
// ==/UserScript==

var links = $('[data-xf-init="preview-tooltip"]');
var tag="<span style='color:#13ff68e8;font-size:10px;'> Jumps to New</span>";
links.unbind( "click" );

$(".p-title-value").html("Watched threads <a class='showunread' data-unread='true'> Show All Threads</a>");
setTimeout(function () {$('.structItem--thread:not(".is-unread")').hide();},250); // hide  all read threads after 1/4 second

$.each( links, function( key, val ) {
    var lnk=$(this);
    var href=lnk.attr("href");
    lnk.unbind( "click" );
    if (href.indexOf("/unread")==-1) { // always set unread tag to go to first unread
        lnk.attr('onclick','window.open("'+href+'unread?new=1"); $(this).css("color","#888888"); return false;'); // alwasy open in new tab
        lnk.attr("href","#"); // preventdefault
        lnk.html(lnk.html()+tag); // set "Jumps to new" indicator
    }
    else {
       lnk.attr('onclick','window.open("'+href+'?new=1"); $(this).css("color","#888888"); return false;'); // alwasy open in new tab
       lnk.attr("href","#");
    }
});

$(".showunread").on('click', function() {
    if ($(this).data("unread")==true) {
        $(".showunread").html("Show Unread Threads");
        $('.structItem--thread').show();
        $(this).data("unread",false);
    }
    else {
        $(".showunread").html("Show All Threads");
        $('.structItem--thread:not(".is-unread")').hide();
        $(this).data("unread",true);
    }
});