Easy Handy Ignore Button Script and CSS


  • Trolleybus Mechanic

    Sometimes you want to ignore a topic. But you can't be fucked to open it up, scroll to the end, and use the (half-hidden) dropdown.

    Well now you don't have to! On your /unread list, you can have a big honking red IGNORE button (with confirmation).

    Uzzascript:

    // ==UserScript==
    // @name        tdwtf - ignore on topic list
    // @namespace   Lorne
    // @include     https://what.thedailywtf.com/*
    // @version     1
    // @grant       all
    // @runat       document-end
    // ==/UserScript==
    
    var $ = unsafeWindow.jQuery;
    
    
    function changeWatching(tid, type, callback){
         callback = callback || function(){}; //callback's optional i guess
         var window = unsafeWindow;
         window.socket.emit('topics.changeWatching', 
            {
                tid: tid,
                type: type
            }, 
            callback);
    }
    
    function watchTopic(tid, callback){
         changeWatching(tid, 'follow', callback);
    }
    
    function normalTopic(tid, callback){
         changeWatching(tid, 'unfollow', callback);
    }
    
    function ignoreTopic(tid, callback){
         changeWatching(tid, 'ignore', callback);
    }
    
    function topicChangeWatchCallback(a,b,c)
    {
        console.log("done ", a, b, c);
    }
    
    $(document).ready(function()
    {
        var $ = unsafeWindow.jQuery;  
    
        $(window).on('action:topics.loaded', function(event, data) 
        {
            $button = $("<a href='#' class='ignore'>IGNORE</a>");
            console.log("topics loaded", event, data);
            $("ul.topic-list>li").each(function(){$(this).append($button.clone())});
            
        });
        
        $(document).on("click", ".topic-list .ignore", function(e)
        {
            console.log("click");
            var tid = $(this).parents("[component='category/topic']:first").attr("data-tid")
    
            if(confirm("Are you sure you want to ignore this topic? " + tid ))
            {
                ignoreTopic(tid, topicChangeWatchCallback);
            }
            return false;
        });
    
        
        
    });
    

    Cascading Shitty Style:

    ul.topic-list .ignore
    {
        border-width:2px !important;
        border-color: #551111 !important;
        border-style:dashed;
        border-radius:5px;
        position:absolute;
        right:0px;
        bottom:0px;
        background-color:#aa0505 !important;
        color:white !important;
        padding:0.5em 1em;
        cursor: pointer;
        
    }
    

    Next version will remove the li from the list, once NodeBB actually puts information in the callback.


Log in to reply