📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Useful script for MSE users

Options
GiGoVX
GiGoVX Posts: 8 Forumite
Name Dropper First Post
edited 13 August at 4:29PM in Compers chat corner
First off I don't consider this 'self-promotion' just a simple post to say I got AI to write something for me for TamperMonkey that help me know which competition links I've pressed on this great forum as I can never remember which ones I've entered without clicking back on the link, this basically saves me time. I also have no association with TamperMonkey in any way shape or form.

TamperMonkey is a extension/browser addon. In there own words:
Tampermonkey is one of the most popular browser extension with over 10 million users.

It allows its users to customize and enhance the functionality of your favorite web pages.
Userscripts are small JavaScript programs that can be used to add new features or 
modify existing ones on web pages. With Tampermonkey, you can easily create, manage, and 
run these userscripts on any website you visit.
I personally use Edge, just search for the extension in the store or any other browser store and I'm sure you'll find it.

Once loaded create a new script and add copy and past the script at the bottom if this post below, save and then you can reload your MSE page and all the links you press from here on out will show up as 'green' to indicate you have visited them.
Example how it looks to me below:


Here is the code, I have only tested this in the latest version of Edge on Windows 11, it should work across all Chromium based browsers and also Firefox.


// ==UserScript==
// @name         MSE Forum – Cross Out Clicked Links (Green)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Cross out competition links in MSE forum when you click/open them; persists your entries.
// @match        https://forums.moneysavingexpert.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
  'use strict';

  const STORAGE_KEY = 'mseCrossedLinks';
  let crossed = new Set(JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]'));

  // Save the updated set to localStorage
  function save() {
    localStorage.setItem(STORAGE_KEY, JSON.stringify(Array.from(crossed)));
  }

  // Apply strikethrough in green
  function styleLink(a) {
    a.style.textDecoration      = 'line-through';
    a.style.textDecorationColor = 'green';  // change this to your preferred colour
    a.style.color               = 'green';  // make the text itself green
    a.style.opacity             = '1';      // full opacity so it’s not faded
  }

  // Process a single link element
  function processLink(a) {
    const href = a.href;
    if (!href || !href.startsWith('http')) return;

    // On load: style any previously clicked URLs
    if (crossed.has(href)) {
      styleLink(a);
    }

    // On any mouse-button down: record & style
    a.addEventListener('mousedown', () => {
      crossed.add(href);
      save();
      styleLink(a);
    });
  }

  // Scan all relevant links in posts and process them
  function scanAndProcess() {
    const selectors = [
      '.Message.userContent a',   // XF1 posts
      '.bbWrapper a',             // XF1 legacy
      '.messageContent a',        // XF2 posts
      '.message-userContent a'    // XF2 alternate
    ];

    selectors.forEach(sel =>
      document.querySelectorAll(sel).forEach(processLink)
    );
  }

  // Initial scan
  scanAndProcess();

  // Re-run on dynamic content loads (pagination, new replies)
  new MutationObserver(scanAndProcess).observe(document.body, {
    childList: true,
    subtree:   true
  });

})();
Again I'm not believing this is self promotion, I'm not gaining anything from this, I'm simple sharing something that has taken about 2 mins to do, it's taken me longer to write this post than to get AI to do this!

Hope others find it useful. You may also discover TamperMonkey can help you with all kind of other competition tasks, I run a few scripts across several sites to automatically enter my details to save me the hassle! 

Comments

  • cooldude255220
    cooldude255220 Posts: 1,594 Forumite
    Part of the Furniture 1,000 Posts Name Dropper Combo Breaker
    edited Today at 10:00AM
    (Removed by Forum Team)
    TamperMonkey is an add-on that allows users to write and run their own scripts. I am sure that the only "connection" GiGoVX has to TamperMonkey is that they have used TamperMonkey's product to make a script.

    For some reason, the userbase on this forum has a hysterical reaction to people "self-promoting" (though I really do not think that's happening here).

    Personally, I would like users to be able to post their own competitions (provided that they declare that they are running the competition, and maybe provided they obtain authorisation from the Guides first). That would allow proper transparency while potentially increasing the number of competitions on here. Provided of course that such authorisation/standing permission could be revoked if there is reason to question the authenticity of the competition or because the user is spamming etc. 
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
  • 351.2K Banking & Borrowing
  • 253.2K Reduce Debt & Boost Income
  • 453.7K Spending & Discounts
  • 244.2K Work, Benefits & Business
  • 599.3K Mortgages, Homes & Bills
  • 177K Life & Family
  • 257.7K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.2K 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.