DDG - remove &ia=

The &ia= parameter doesn't always appear. This removes it to streamline the history log.

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 or Violentmonkey 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         DDG - remove &ia=
// @namespace    https://github.com/Procyon-b
// @version      1.0
// @description  The &ia= parameter doesn't always appear. This removes it to streamline the history log.
// @author       Achernar
// @match        https://duckduckgo.com/*
// @match        https://*.duckduckgo.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
"use strict";

var hreplaceState=history.replaceState;
history.replaceState=function(a,b,u){
  if (u && u.includes('&ia=')) {
    u=u.replace(/&ia=[^&]+/, '');
    }
  return hreplaceState.apply(history, [a,b,u]);
  }

var hpushState=history.pushState;
history.pushState=function(a,b,u){
  if (u && u.includes('&ia=')) {
    u=u.replace(/&ia=[^&]+/, '');
    }
  return hpushState.apply(history, [a,b,u]);
  }


var inited=0;
function init(){
  if (inited++) return;
  new MutationObserver(function(mutL){
    for(let mut of mutL) {
      if (mut.target && (mut.target.id=='react-duckbar') ) {
        fix(mut.target);
        return;
        }
      }
    }).observe(document.body, { attributes: false, childList: true, subtree: true});
  fix();
  }

function fix(r=document) {
  var a=r.querySelectorAll('a[href*="ia="]');
  for (let i=0,e; e=a[i]; i++) {
    e.search=e.search.replace(/&ia=[^&]+/, '');
    }
  }

if (document.readyState != 'loading') init();
else {
  document.addEventListener('DOMContentLoaded', init);
  window.addEventListener('load', init);
  }


})();