AMP redirect

View Google AMP version of pages

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         AMP redirect
// @namespace    http://tampermonkey.net/
// @version      2024-03-02
// @description  View Google AMP version of pages
// @author       oldflumpy
// @match        https://www.sample.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

/* relpace sample.com with the website of your choice :) */

(function() {
    'use strict';
    var oldUrlPath = window.location;
    var searchParams = window.location.search;
    var ampPattern = /\?outputType=amp/;
/* check to see if param is already present or not needed */
    if (!ampPattern.test(searchParams) &&
       window.location.pathname.length > 1) {
        var newURL = oldUrlPath + '?outputType=amp';
        window.location.replace (newURL);
    }
})();