Free Game Alert (Old Reddit)

Highlight posts containing the word "free"

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Free Game Alert (Old Reddit)
// @namespace    http://tampermonkey.net/
// @version      2025.06.20
// @description  Highlight posts containing the word "free"
// @author       SwanKnight
// @match        https://old.reddit.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant        none
// @license     GPLv3
// ==/UserScript==

(function() {
    'use strict';

    var elements = document.getElementsByClassName("title");

    // Convert HTMLCollection to an array
    Array.from(elements).forEach(element => {
        const regex = /\bfree\b/i;
        const regex2 = /\bweekend\b/i;
        var str = element.textContent.toLowerCase();
        if (regex2.test(str) == false && (regex.test(str) || str.includes('$0/100%'))) {
            var parentDiv = element.closest('div.top-matter');
            if (parentDiv) {
                parentDiv.style.backgroundColor = "lightgreen"; // Change the background color of the parent div
            }
        }
    });
})();