Advent Competitions Tampermonkey Script

Dumdeedum
Dumdeedum Posts: 38 Forumite
Part of the Furniture 10 Posts
edited 11 December 2022 at 7:23PM in Compers chat corner
A while back now I posted a Tampermonkey/Greasemonkey script I'd made that added and adjusted some things to to competitions page to make things a bit quicker, and finally got round to making a few tweaks to it so it works on the advent comps too.  It works slightly differently to the regular comps script, rather than highlighting new unseen competitions it highlights ones you've green ticked and fades out ones you've marked to skip (ones with neither remain white).  The other adjustments are still there, so you end up with something like this:



If you want to use it then all the disclaimers from the original script apply, but here it is:

// ==UserScript==
// @name         Spiffier Advent Comps Time
// @namespace    http://tampermonkey.net/
// @version      2
// @description  Make the ADVENT competitions time forum a bit more streamlined and usable
// @author       Dumdeedum
// @match        https://forums.moneysavingexpert.com/categories/advent-competitions*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
    // tiny bugfix to prevent horizonal scroll on Chrome
    $("nav.mse-navigation").css("width", "100%");

    // better prev/next links
    $("a.Previous").html("< Prev");
    $("a.Next").html("Next >");

    // right and left arrows for navigation
    $(document).keyup(function(evnt) {
       if((evnt.which == 37) || (evnt.which == 39)) {
          if(evnt.which == 37) {
              newurl = $("a.Previous").attr("href");
          }
          else {
              newurl = $("a.Next").attr("href");
          }
          evnt.preventDefault();
          document.location.assign(newurl);
       }
    });

    // shift the Create Post button over to the main bitty, and tweak its display slightly to stay tidy(ish)
    $("div.NewDiscussion:first").insertBefore("main.MainContent h1.HomepageTitle").css({"position": "absolute", "right": "35px", "max-width": "250px"});
    $("main.MainContent div.NewDiscussion a:first").css("padding", "0px");

    // zap the whole left navigation pane out of existence
    $("aside.Panel").remove();

    // spread the main panel out in all the lovely new space
    $("main.MainContent").css("width", "100%");

    // pad the listing boxes a bit, and tart the headings too
    $("li.Item").css("padding", "3px");
    $("li.Item div.Title").css({"font-weight": "normal", "font-size": "18px"});

    // run through each competition listed
    $("li.ItemDiscussion").not(".Announcement").each(function() {
        // pick out some info we might need
        var compViews = $("span.ViewCount", this).first().text();
        var compReplies = $("span.CommentCount", this).first().text();
        var compLastCommentDate = $("span.LastCommentDate > time", this).first().text();
        var compLastCommentDateTime = $("span.LastCommentDate > time", this).first().attr("datetime");

        // if the comp has green-tick, highlight it
        if($("label.CompetitionStatusToggle-label.Entered.checked", this).length) {
            // highlight this listing
            $(this).css("background-color", "#fff2c6");
        }

        // or if the comp has red tick, fade it out
        else if($("label.CompetitionStatusToggle-label.Skipped.checked", this).length) {
            $(this).css("opacity", "0.4");
        }

        // hide the info stuff on the right, it's just taking up space
        $("div.DiscussionMeta", this).hide();

        // and with the new space, stretch the main title over
        $("div.Discussion", this).css("width", "100%");

        // and bump the skipped/entered label over too
        $("span.CompetitionStatus", this).css("right", "20px");

        // hide the ugly-!!!!!! "new posts" box
        $("strong.HasNew").hide();

        // rejigger the info line
        $("span.FirstCommentBy", this).prepend("By ").append(" | " + compViews + " | " + compReplies + " | " + compLastCommentDate).css("color", "#6f6f6f");
        $("span.FirstCommentBy a", this).css({"font-size" : "14px", "font-weight" : "bold"});

    });


})();
I realise that this probably isn't a tool for everyone, or possibly for anyone other than me, but it saves me a ton of time given I only enter about a dozen out of the million advent competitions, so maybe it can help some other tech-savvy comper too.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.1K Banking & Borrowing
  • 252.8K Reduce Debt & Boost Income
  • 453.1K Spending & Discounts
  • 243.1K Work, Benefits & Business
  • 597.4K Mortgages, Homes & Bills
  • 176.5K Life & Family
  • 256K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.