TamperMonkey Google Trends RSS > Kagi News Search

I sub to Google Trends RSS to see what the most popular searches are for the day. The problem is that Google Trends sucks for finding out more. With this script, clicking on a Google Trend will bring you to the Kagi.com news search to find out more.

Just load this up in your browser’s TamperMonkey extension and you’re set!

// ==UserScript==
// @name         Google Trends to Kagi News Redirector
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Redirect Google Trends to today's Kagi News
// @author       CMcG
// @match        https://trends.google.com/trends/trendingsearches/daily*
// @match        https://rss.mcwain.net/tt-rss/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Detect if the current URL contains a query parameter
    const urlParams = new URLSearchParams(window.location.search);
    const geoParam = urlParams.get('geo');

    // Check if the required geo parameter is as expected
    if (geoParam === 'US') {
        // Extract the hash part which seems to represent the search term
        const searchTerm = window.location.hash.substring(1); // Remove the leading '#'

        // Decode the search term to remove URL encoding like %20
        const decodedSearchTerm = decodeURIComponent(searchTerm);

        // Re-encode the search term properly for the URL
        const kagiUrl = `https://kagi.com/news?q=${encodeURIComponent(decodedSearchTerm)}&freshness=1`;
Previous: Things I Use Next: The Bricklayer