kalpdev.1 / KeyLight 4

// ==UserScript==
// @name          KeyLight 4
// @namespace     kalpsdj
// @author        Shjaisw
// @license       MIT
// @updateURL     https://openuserjs.org/meta/kalpdev.1/KeyLight_4.meta.js
// @downloadURL   https://openuserjs.org/install/kalpdev.1/KeyLight_4.user.js
// @run-at        document-end
// @version       3.6
// @description   Highlights Connecting words
// @include       https://*
// @exclude       https://*google*
// @exclude       https://argus.aka.amazon.com/*
// @exclude       https://issues.amazon.com/*
// @grant         GM_registerMenuCommand
// @grant         GM_setValue
// @grant         GM_getValue
// ==/UserScript==


 // Do not make any changes/delete any script,line no 13. We are not responsible for any changes in script. Do not allow script to run on argus.  


(function() { // Highlight Connecting words Realated product details
  'use strict';

  if (window.self !== window.top) { return; }


  function setUserPref(varName, defaultVal, menuText, promtText, sep){
    GM_registerMenuCommand(menuText, function() {
      var val = prompt(promtText, GM_getValue(varName, defaultVal));
      if (val === null)  { return; }

      if (sep && val){
        var pat1 = new RegExp('\\s*' + sep + '+\\s*', 'g');
        var pat2 = new RegExp('(?:^' + sep + '+|' + sep + '+$)', 'g'); // trim starting & trailing separator
        val = val.replace(pat1, sep).replace(pat2, '');
      }
      val = val.replace(/\s{2,}/g, ' ').trim();
      GM_setValue(varName, val);

      if(!document.body.querySelector(".THmo")) THmo_doHighlight(document.body);
      else location.reload();
    });
  }


  var THmo_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
  if (THmo_MutOb){
    var THmo_chgMon = new THmo_MutOb(function(mutationSet){
      mutationSet.forEach(function(mutation){
        for (var i=0; i<mutation.addedNodes.length; i++){
          if (mutation.addedNodes[i].nodeType == 1){
            THmo_doHighlight(mutation.addedNodes[i]);
          }
        }
      });
    });
    // attach chgMon to document.body
    var optss = {childList: true, subtree: true};
    THmo_chgMon.observe(document.body, optss);
  }



  function THmo_doHighlight(el){
    var sdj = GM_getValue('sdj');
    if(!sdj)  sdj="zipo,SELF- INFLATING,LIFE-SAVING,inbuilt,Impulse,every,step,Long,Skecher,Twinkle,Dinosoles,Heelys,Crocs,Under,HOVR,Sensor,Armour,Q-Chip,Gel pads,Dry Ice,Package details,what's in the box,jack,Shaving repellent oil,clipper oil,Mercury,Wired,Quartz,package,package include,includes,included,inflatable,Soda stream,camphor,Ammonium Hydroxyde,cadmium,nickel,lead,explosives,explosive,Crackers,toner,primer,remover,away from flame,self inflating,lead,kit,Sealed,refrigerant,refrigerator,Compressor,O2,CO2,Carbon dioxide,Carbon di oxide,oxygen,Fatal if swallowed,ionization,cancer,Oxidizer,hazardous,combustible,Combustible Liquid,COMBUSTIBLE LIQUID, N.O.S.,diffuser,fragrance,dnet,repair kit,Ethanol,acetic,glycolic,acetone,methyl,acetate,ethyl,cyclotetrasiloxane,isopropyl,dry erase ,dry erase marker,Methanol,Isododecane,Isopropanol,Isopropane,Isobutene,kerosene,Naphthalenes,phenol,Difluroethane,tetrafluroethane,Dimethylcarbinol,Sodium hydroxide,Denatured,Isobutylene,isopentane,pentane,isobutane,nitric,sulphuric,urea,carbamide,hydrogen peroxide,carbon filter,toxic,corrosive,Corrosive Liquid ,photoelectric,markers,marker,chalk,snap,snaps,charcoal,top coat,base coat,basecoat,topcoat,extinguisher,radioactive,tritium,cartridges,cartridge,igniters,magnesium,ferrocerium,flint,propellant,Moisturizer,Moisturizing,Grease,wax,Glue sticks,essential oils,essential oil,motor oil,Massage oil,Lighters,Lighter,roll-on,roll on,party popper,smoke detector,air freshener,Fire Extinguishers,Fire Starters,acrylic ink,Tattoo ink,wipes,baby wipes,baby wipe,eyeliner,eye drop,eye drops,eye shadow,E-liquid,shampoo,hot pack,ice pack,cold pack,polish,Airbags,nicotine,tobacco,Ittar,Attar,sanitizer,hand sanitizer,lotion,cream,serum,perfume,deodorant,developer,activator,paint,gel nail paint,cleaner,matches,match,match box,gefahrgut,adhesives,adhesive,Alcohol,SD alcohol,flammable,flammable liquid,no nicotine,butan,propan,butane,propane,aerosols,aerosol,spray,cooking spray,Hairspray,under pressure,gas under pressure,contents under pressure,content under pressure"
    var sdjc = GM_getValue('sdjc');
    if (!sdjc) sdjc = "color: #000; font-weight: bold; background-color: #58fcb8;"

    var rQuantifiers = /[-\/\\^$*+?.()|[\]{}]/g;
    sdj = sdj.replace(rQuantifiers, '\\$&').split(',').join('|');
    var pat = new RegExp('(' + sdj + ')', 'gi');
    var span = document.createElement('span');

    var snapElements = document.evaluate(
        './/text()[normalize-space() != "" ' +
        'and not(ancestor::style) ' +
        'and not(ancestor::script) ' +
        'and not(ancestor::textarea) ' +
        'and not(ancestor::code) ' +
        'and not(ancestor::pre)]',
        el, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

    if (!snapElements.snapshotItem(0)) { return; }

    for (var i = 0, len = snapElements.snapshotLength; i < len; i++) {
      var node = snapElements.snapshotItem(i);

      if (pat.test(node.nodeValue)) {

        if (node.className != "THmo" && node.parentNode.className != "THmo"){

          var sp = span.cloneNode(true);
          sp.innerHTML = node.nodeValue.replace(pat, '<span style="' + sdjc + '" class="THmo">$1</span>');
          node.parentNode.replaceChild(sp, node);
        }
      }
    }
  }

  // first run
  THmo_doHighlight(document.body);
})();