Opera Browser Rocker+Mouse Gestures + Search HighLight

This script works on any browser and simulates the Opera Browser Mouse+Rocker Gestures, along with the Search HighLight and Units+Currency Converters, but with this script you can modify or disable them as you want.

Install this script?
Author's suggested script

You may also like Precise Time Converter on Google.

Install this script
// ==UserScript==
// @name               Opera Browser Rocker+Mouse Gestures + Search HighLight
// @namespace          OperaBrowserGestures
// @description        This script works on any browser and simulates the Opera Browser Mouse+Rocker Gestures, along with the Search HighLight and Units+Currency Converters, but with this script you can modify or disable them as you want.
// @version            58
// @author             hacker09
// @include            *
// @icon               https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://www.opera.com/&size=64
// @require            https://greasyfork.org/scripts/446666-jquery-core-minified/code/jQuery%20Core%20minified.js
// @grant              GM_registerMenuCommand
// @grant              GM.xmlHttpRequest
// @grant              GM_deleteValue
// @grant              GM_openInTab
// @grant              window.close
// @run-at             document-end
// @grant              GM_setValue
// @grant              GM_getValue
// @connect            google.com
// ==/UserScript==

// *** Mouse Gesture Settings Below *****************************************************************************************************************************************
GM_registerMenuCommand("Enable/Disable Mouse Gestures", MouseGestures); //Adds an option to the tampermonkey menu
if (GM_getValue("MouseGestures") !== true && GM_getValue("MouseGestures") !== false) { //If the value doesn't exist define as true
  GM_setValue("MouseGestures", true); //Defines the variable as true
} //Finishes the if condition

function MouseGestures() //Function to enable or disable the MouseGestures
{ //Starts the function MouseGestures
  if (GM_getValue("MouseGestures") === true) { //If the last config was true, set as false
    GM_setValue("MouseGestures", false); //Defines the variable as false
  } //Finishes the if condition
  else { //If the last config was false, set as true
    GM_setValue("MouseGestures", true); //Defines the variable as true
    location.reload(); //Reloads the page
  } //Finishes the else condition
} //Finishes the function MouseGestures

if (GM_getValue("MouseGestures") === true) //If the MouseGestures is enabled
{ //Starts the if condition
  const SENSITIVITY = 3; // Adjust the script mouse sensitivity here between 1 ~ 5
  const TOLERANCE = 3; // Adjust the script mouse tolerance here between  1 ~ 5

  const funcs = { //Variable to store the functions

    'L': function() { //Function that will run when the mouse movement Left is performed
      window.history.back(); //Go Back
    }, //Finishes the mouse movement Left

    'R': function() { //Function that will run when the mouse movement Right is performed
      window.history.forward(); //Go Forward
    }, //Finishes the mouse movement Right

    'D': function() { //Function that will run when the mouse movement Down is performed
      if (IsShiftNotPressed === true) { //If the shift key isn't being pressed
        GM_openInTab(link, { //Open the link on a new tab
          active: true, //Focus on the new tab
          insert: true, //Insert the new tab after the actual tab
          setParent: true //Return to the tab the user was in
        }); //Open the link that was hovered
      } //Finishes the if condition
    }, //Finishes the mouse movement Down

    'UD': function() { //Function that will run when the mouse movement Up+Down is performed
      location.reload(); //Reload the Tab
    }, //Finishes the mouse movement Up+Down

    'DR': function(e) { //Function that will run when the mouse movement Down+Right is performed
      top.close(); //Close the tab
      e.preventDefault(); //Prevent the default context menu from being opened
      e.stopPropagation(); //Prevent the default context menu from being opened
    }, //Finishes the mouse movement Down+Right

    'DU': function() { //Function that will run when the mouse movement Down+Up is performed
      GM_openInTab(link, { //Open the link that was hovered
        active: false, //Don't focus on the new tab
        insert: true, //Insert the new tab after the actual tab
        setParent: true //Return to the tab the user was in
      }); //Open the link that was hovered on a new background tab
    } //Finishes the mouse movement Down+Up

  }; //Finishes the variable to store the functions

  // *** Below this line is the math codes that track the mouse movement gestures *******************************************************************************************
  const s = 1 << ((7 - SENSITIVITY) << 1);
  const t1 = Math.tan(0.15708 * TOLERANCE),
    t2 = 1 / t1;

  let x, y, path;

  const tracer = function(e) { //Starts the const tracer
    let cx = e.clientX,
      cy = e.clientY,
      deltaX = cx - x,
      deltaY = cy - y,
      distance = deltaX * deltaX + deltaY * deltaY;
    if (distance > s) {
      let slope = Math.abs(deltaY / deltaX),
        direction = '';
      if (slope > t1) {
        direction = deltaY > 0 ? 'D' : 'U';
      } else if (slope <= t2) {
        direction = deltaX > 0 ? 'R' : 'L';
      }
      if (path.charAt(path.length - 1) !== direction) {
        path += direction;
      }
      x = cx;
      y = cy;
    }
  }; //Finishes the const tracer

  window.addEventListener('mousedown', function(e) { //Add an event listener to the page to detect when the mouse is clicked
    if (e.which === 3) { //Starts the if condition
      x = e.clientX;
      y = e.clientY;
      path = "";
      window.addEventListener('mousemove', tracer, false); //Add an event listener to the page to detect the mouse position
    } //Finishes the if condition
  }, false); //Finishes the event listener

  var IsShiftNotPressed = true; //Variable to hold the shift key status
  window.addEventListener("contextmenu", function(e) { //Adds an event listener to the page to know when the shift key is pressed or not
    if (e.shiftKey) { //If the shift key was pressed
      IsShiftNotPressed = false; //Variable to hold the shift key status
      open(link, '_blank', 'height=' + screen.height + ',width=' + screen.width); //Open the link on a new window
    } //Finishes the if condition
    if (LeftClicked === true) { //If the Left Click was released when the Rocker Mouse Gestures were activated
      e.preventDefault(); //Prevent the default context menu from being opened
      e.stopPropagation(); //Prevent the default context menu from being opened
    } //Finishes the if condition
    setTimeout(function() { //Starts the set timeout function
      IsShiftNotPressed = true; //Variable to hold the shift key status
    }, 500); //Finishes the set timeout function
  }, false); //Finishes the event listener

  window.addEventListener('contextmenu', function(e) { //When the right click button is released
    window.removeEventListener('mousemove', tracer, false); //Stop tracking the mouse movements
    if (path !== "") { //Starts the if condition
      e.preventDefault(); //Prevent the default context menu from being opened
      if (funcs.hasOwnProperty(path)) { //Starts the if condition
        funcs[path]();
      } //Finishes the if condition
    } //Finishes the if condition
  }, false); //Finishes the event listener

  var link; //Make the variable global
  Array.from(document.querySelectorAll('a')).forEach(Element => Element.onmouseover = function() { //Get all the a link elements and add an event listener to the link element
    link = this.href; //Store the actual hovered link to a variable
  }); //Finishes the forEach

  Array.from(document.querySelectorAll('a')).forEach(Element => Element.onmouseout = function() { //Get all the a link elements and add an event listener to the link element
    var PreviousLink = link; //Save the actual hovered link to another variable
    setTimeout(function() { //Starts the set timeout function
      if (PreviousLink === link) //If the actual hovered link is still the same as the previously hovered Link
      { //Starts the if condition
        link = 'about:newtab'; //Make the script open a new browser tab when the mouse leaves any link that was hovered
      } //Finishes the if condition
    }, 200); //Finishes the set timeout function
  }); //Finishes the forEach

} //Finishes the if condition

// *** Rocker Mouse Gesture Settings Below ***********************************************************************************************************************************
GM_registerMenuCommand("Enable/Disable Rocker Mouse Gestures", RockerMouseGestures); //Adds an option to the tampermonkey menu
if (GM_getValue("RockerMouseGestures") !== true && GM_getValue("RockerMouseGestures") !== false) { //If the value doesn't exist define as false
  GM_setValue("RockerMouseGestures", false); //Defines the variable as false
} //Finishes the if condition

function RockerMouseGestures() //Function to enable or disable the RockerMouseGestures
{ //Starts the function RockerMouseGestures
  if (GM_getValue("RockerMouseGestures") === true) { //If the last config was true, set as false
    GM_setValue("RockerMouseGestures", false); //Defines the variable as false
  } //Finishes the if condition
  else { //If the last config was false, set as true
    GM_setValue("RockerMouseGestures", true); //Defines the variable as true
    location.reload(); //Reloads the page
  } //Finishes the else condition
} //Finishes the function RockerMouseGestures

if (GM_getValue("RockerMouseGestures") === true || GM_getValue("SearchHiLight") === true) //If the RockerMouseGestures or the SearchHiLight is enabled
{ //Starts the if condition
  var LeftClicked, RightClicked; //Make these variables global
  window.addEventListener("mousedown", function(e) { //Detect the right and left mouse clicks presses on the page
    switch (e.button) { //Start the switch condition
      case 0: //If Left Click was Pressed
        LeftClicked = true; //Set the variable LeftClicked as true
        break; //Don't execute the lines below if the Left Key was Pressed
      case 2: //If Right Click was Pressed
        RightClicked = true; //Set the variable RightClicked as true
        break; //Don't execute the lines below if the Right Key was Pressed
    } //Finishes the switch condition
  }, false); //Finishes the event listener mouse down

  window.addEventListener("mouseup", function(e) { //Detect the right and left mouse clicks releases on the page
    switch (e.button) { //Start the switch condition
      case 0: //If Left Click was released
        LeftClicked = false; //Set the variable LeftClicked as false
        break; //Don't execute the lines below if the Left Key was Pressed
      case 2: //If Right Click was released
        RightClicked = false; //Set the variable RightClicked as false
        break; //Don't execute the lines below if the Left Key was Pressed
    } //Finishes the switch condition
    if (LeftClicked && RightClicked === false) { //If Left was Clicked and then Right Click was released
      history.back(); //Go Back
    } //Finishes the if condition
    if (RightClicked && LeftClicked === false) { //If Right was Clicked and then Left Click was released
      history.forward(); //Go Forward
    } //Finishes the if condition
  }, false); //Finishes the event listener mouse up
} //Finishes the if condition

// *** SearchHighLight Below *************************************************************************************************************************************************
GM_registerMenuCommand("Enable/Disable SearchHiLight", SearchHiLight); //Adds an option to the tampermonkey menu
if (GM_getValue("SearchHiLight") !== true && GM_getValue("SearchHiLight") !== false) { //If the value doesn't exist define as true
  GM_setValue("SearchHiLight", true); //Defines the variable as true
} //Finishes the if condition

if (GM_getValue("CurrenciesConverter") !== true && GM_getValue("CurrenciesConverter") !== false) { //If the value doesn't exist define as true
  GM_setValue("CurrenciesConverter", true); //Defines the variable as true
} //Finishes the if condition

if (GM_getValue("UnitsConverter") !== true && GM_getValue("UnitsConverter") !== false) { //If the value doesn't exist define as true
  GM_setValue("UnitsConverter", true); //Defines the variable as true
} //Finishes the if condition

function SearchHiLight() //Function to enable or disable the SearchHiLight and the Currency/Unit converters
{ //Starts the function SearchHiLight
  if (GM_getValue("SearchHiLight") === true) { //If the last config was true, set as false
    GM_setValue("SearchHiLight", false); //Defines the variable as false
    GM_setValue("CurrenciesConverter", false); //Defines the variable as false
    GM_deleteValue('YourLocalCurrency'); //Remove the YourLocalCurrency variable of the tampermonkey storage
    GM_setValue("UnitsConverter", false); //Defines the variable as false
  } //Finishes the if condition
  else { //If the last config was false, set as true
    GM_setValue("SearchHiLight", true); //Defines the variable as true

    if (confirm('If you want to enable the Currency Converter press OK.')) //Show the confirmation alert box text
    { //Starts the if condition
      GM_setValue("CurrenciesConverter", true); //Defines the variable as true
    } //Finishes the if condition
    else //If the user pressed cancel
    { //Starts the else condition
      GM_setValue("CurrenciesConverter", false); //Defines the variable as false
    } //Finishes the else condition

    if (confirm('If you want to enable the Units Converter press OK.')) //Show the confirmation alert box text
    { //Starts the if condition
      GM_setValue("UnitsConverter", true); //Defines the variable as true
    } //Finishes the if condition
    else //If the user pressed cancel
    { //Starts the else condition
      GM_setValue("UnitsConverter", false); //Defines the variable as false
    } //Finishes the else condition

    location.reload(); //Reloads the page
  } //Finishes the else condition
} //Finishes the function SearchHiLight

if (GM_getValue("SearchHiLight") === true) //If the SearchHiLight is enabled
{ //Starts the if condition

  var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
  var SelectedTextIsLink; //Creates a new global variable
  var Links = new RegExp(/\.org|\.ly|\.net|\.co|\.tv|\.me|\.biz|\.club|\.site|\.br|\.gov|\.io|\.jp|\.edu|\.au|\.in|\.it|\.ca|\.mx|\.fr|\.tw|\.il|\.uk|\.zoom\.us|\youtu.be/i); //Creates a global variable to check if a link is matched
  var FinalCurrency, SelectedText, SelectedTextSearch = ''; //Make these variables global

  $(function() { //Starts the function
    var menu = $("#highlight_menu", $("#highlight_menu_div")[0].shadowRoot); //Creates a variable to hold the menu element
    document.body.addEventListener('mouseup', function() { //When the user releases the mouse click after selecting something
      SelectedText = getSelection().toString(); //Creates a variable to store the selected text
      SelectedTextSearch = getSelection().toString().replaceAll('&', '%26'); //Creates a variable to store the selected text to be opened on Google

      if (GM_getValue("CurrenciesConverter") === true) { //If the Currencies Converter option is activated
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = ''; //Remove the previous Currency text
        var Currencies = new RegExp(/^[ \t\xA0]*(?=.*?(\d+(?:.\d+)?))(?=(?:\1[ \t\xA0]*)?(Dólares|dolares|dólares|dollars|AUD|BGN|BRL|BCH|BTC|BYN|CAD|CHF|CNY|CZK|DKK|EUR|EGP|ETH|GBP|GEL|HKD|HRK|HUF|IDR|ILS|INR|JPY|LTC|KRW|MXN|MYR|NOK|NZD|PHP|PLN|RON|RM|RUB|SEK|SGD|THB|TRY|USD|UAH|ZAR|KZT|YTL|\$|R\$|HK\$|US\$|\$US|¥|€|Rp|kn|Kč|kr|zł|£|฿|₩))(?:\1[ \t\xA0]*\2|\2[ \t\xA0]*\1)[ \t\xA0]*$/i); //Adds an regex expression to the Currencies variable

        if (SelectedText.match(Currencies) !== null) //If the selected text is a currency
        { //Starts the if condition

          if (GM_getValue("YourLocalCurrency") === undefined) { //If the value is undefined
            var UserInput = prompt('This is the first time that you selected a currency.\nThis is the first and last time this popup will appear, so please write your local currency so that the script will always use your local currency to make exchange-rate conversions.\n*Example of what you should write: BRL\nCAD\nUSD\netc...\n*Press OK'); //Gets the user input
            GM_setValue("YourLocalCurrency", UserInput); //Defines the variable as the UserInput
          } //Finishes the if condition

          (async () => { //Creates a function to get the final value
            var CurrencySymbol = SelectedText.match(Currencies)[2]; //Get the actual currency symbol supposing "it's correct"
            var CurrencySymbols = new RegExp(/\$|R\$|HK\$|US\$|\$US|¥|€|Rp|kn|Kč|kr|zł|£|฿|₩/i); //Create a variable to check for the selected currency symbols
            if (SelectedText.match(Currencies)[2].match(CurrencySymbols) !== null) //If the selected currency contains a symbol
            { //Starts the if condition

              switch (SelectedText.match(CurrencySymbols)[0].toLowerCase()) { //If the selected currency contains a symbol
                case '$': //Get the actual selected currency symbol
                case 'us$': //Get the actual selected currency symbol
                case '$us': //Get the actual selected currency symbol
                  CurrencySymbol = 'USD'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'r$': //Get the actual selected currency symbol
                  CurrencySymbol = 'BRL'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'hk$': //Get the actual selected currency symbol
                  CurrencySymbol = 'HKD'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case "¥": //Get the actual selected currency symbol
                  CurrencySymbol = 'JPY'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case '€': //Get the actual selected currency symbol
                  CurrencySymbol = 'EUR'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'rp': //Get the actual selected currency symbol
                  CurrencySymbol = 'IDR'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'kn': //Get the actual selected currency symbol
                  CurrencySymbol = 'HRK'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'kč': //Get the actual selected currency symbol
                  CurrencySymbol = 'CZK'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'kr': //Get the actual selected currency symbol
                  CurrencySymbol = 'DKK'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case 'zł': //Get the actual selected currency symbol
                  CurrencySymbol = 'PLN'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case '£': //Get the actual selected currency symbol
                  CurrencySymbol = 'GBP'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case '฿': //Get the actual selected currency symbol
                  CurrencySymbol = 'THB'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
                case '₩': //Get the actual selected currency symbol
                  CurrencySymbol = 'KRW'; //"Convert" the symbol to the Currency Letters
                  break; //Stop trying to get the correct Currency Letters
              } //Finishes the switch condition
            } //Finishes the if condition

            GM.xmlHttpRequest({
              method: "GET",
              url: `https://www.google.com/search?q=${SelectedText.match(Currencies)[1]} ${CurrencySymbol} in ${GM_getValue("YourLocalCurrency")}`,
              onload: (response) => {
                const newDocument = new DOMParser().parseFromString(response.responseText, 'text/html'); //Parses the fetch response
                const FinalCurrency = parseFloat(newDocument.querySelector(".SwHCTb").innerText.split(' ')[0].replaceAll(',', ''));

                if (SelectedText.match(Currencies)[2].match(CurrencySymbols) !== null) { //If the selected currency contains a symbol
                  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = CurrencySymbol + ' 🠂 ' + Intl.NumberFormat(navigator.language, {
                    style: 'currency',
                    currency: GM_getValue("YourLocalCurrency")
                  }).format(FinalCurrency) + ' | '; //Show the FinalCurrency on the menu
                } else { //If the selected currency contains no symbol
                  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = Intl.NumberFormat(navigator.language, {
                    style: 'currency',
                    currency: GM_getValue("YourLocalCurrency")
                  }).format(FinalCurrency) + ' | '; //Show the FinalCurrency on the menu
                }

                var text = document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText; //Save the actual currency text
                document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onmousemove = function() { //When the mouse is hovering the currency
                  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = "Copy | "; //Change the element text to copy
                }; //Finishes the onmousemove event listener

                document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onmouseout = function() { //When the mouse leaves the button
                  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = text; //Return the previous text
                }; //Finishes the onmouseout event listener

                document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onclick = function() { //When the user clicks on the currency
                  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = "Done | "; //Change the element text to copy
                  navigator.clipboard.writeText(Intl.NumberFormat(navigator.language, {
                    style: 'currency',
                    currency: GM_getValue("YourLocalCurrency")
                  }).format(FinalCurrency)); //Copy the Final Currency
                }; //Finishes the onclick event listener
              }
            });

          })(); //Finishes the async function
        } //Finishes the if condition
      } //Finishes the if condition
      //___________________________________________________________________________________________________________________________________________________________________________

      if (GM_getValue("UnitsConverter") === true) { //If the Units Converter option is activated
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = ''; //Remove the previous Units text
        var Units = new RegExp(/^[ \t\xA0]*(-?\d+(?:[., ]\d+)?)[ \t\xA0]*("|inch|inches|in|cms?|centimeters?|meters?|ft|kg|lbs?|pounds?|kilograms?|ounces?|g|ozs?|fl oz|fl oz (us)|fluid ounces?|kphs?|km\/h|kilometers per hours?|mphs?|meters per hours?|°?º?[CF]|km\/hs?|ml|milliliters?|l|liters?|litres?|gal|gallons?|yards?|yd|Millimeter|millimetre|kilometers?|mi|mm|miles?|km|ft|fl|feets?|mts?|grams?|kilowatts?|kws?|brake horsepower|mechanical horsepower|hps?|bhps?|miles per gallons?|mpgs?|liters per 100 kilometers?|l\/100km|liquid quarts?|lqs?|foot-?pounds?|ft-?lbs?|lb fts?|newton-?meters?|nm|\^\d+)[ \t\xA0]*(?:\(\w+\)[ \t\xA0]*)?$/i); //Adds an regex expression to the Units variable

        if (SelectedText.match(Units) !== null) //If the selected text is an unit
        { //Starts the if condition

          var SelectedUnitValue = SelectedText.match(Units)[1].replaceAll(',', '.'); //Get the selected unit value and store the value to a variable

          switch (SelectedText.match(Units)[2].toLowerCase()) { //Set all letters to Lower Case and convert the selected unit to another unit the same way the Opera Browser does
            case 'inch': //Get the actual selected unit type
            case 'inches': //Get the actual selected unit type
            case 'in': //Get the actual selected unit type
            case '"': //Get the actual selected unit type
              var NewUnit = 'cm'; //"Convert" the current unit to another unit
              var ConvertedUnit = parseFloat(SelectedUnitValue * 2.54).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'centimeter': //Get the actual selected unit type
            case 'centimeters': //Get the actual selected unit type
            case 'cm': //Get the actual selected unit type
            case 'cms': //Get the actual selected unit type
              NewUnit = 'in'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 2.54).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mt': //Get the actual selected unit type
            case 'mts': //Get the actual selected unit type
            case 'meters': //Get the actual selected unit type
            case 'meter': //Get the actual selected unit type
              NewUnit = 'ft'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 3.281).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'kg': //Get the actual selected unit type
            case 'kilograms': //Get the actual selected unit type
            case 'kilogram': //Get the actual selected unit type
              NewUnit = 'lb'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 2.205).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'pound': //Get the actual selected unit type
            case 'pounds': //Get the actual selected unit type
            case 'lb': //Get the actual selected unit type
            case 'lbs': //Get the actual selected unit type
              NewUnit = 'kg'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 2.205).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'ounce': //Get the actual selected unit type
            case 'ounces': //Get the actual selected unit type
            case 'oz': //Get the actual selected unit type
            case 'ozs': //Get the actual selected unit type
              NewUnit = 'g'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 28.35).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'g': //Get the actual selected unit type
            case 'gram': //Get the actual selected unit type
            case 'grams': //Get the actual selected unit type
              NewUnit = 'oz'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 28.35).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'kilometer': //Get the actual selected unit type
            case 'kilometers': //Get the actual selected unit type
              NewUnit = 'mi'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.609).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'kph': //Get the actual selected unit type
            case 'kphs': //Get the actual selected unit type
            case 'km/h': //Get the actual selected unit type
            case 'km/hs': //Get the actual selected unit type
            case 'kilometers per hour': //Get the actual selected unit type
            case 'kilometers per hours': //Get the actual selected unit type
              NewUnit = 'mph'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 1000).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mph': //Get the actual selected unit type
            case 'mphs': //Get the actual selected unit type
            case 'meters per hour': //Get the actual selected unit type
            case 'meters per hours': //Get the actual selected unit type
              NewUnit = 'km/h'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.000).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mi': //Get the actual selected unit type
            case 'mile': //Get the actual selected unit type
            case 'miles': //Get the actual selected unit type
              NewUnit = 'km'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 1.609).toFixed(2); //Gets the converted unit result
              break; //Stop
            case '°c': //Get the actual selected unit type
              NewUnit = '°F'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat((SelectedUnitValue * 9 / 5) + 32).toFixed(2); //Gets the converted unit result
              break; //Stop
            case '°f': //Get the actual selected unit type
              NewUnit = '°C'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat((SelectedUnitValue - 32) * 5 / 9).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'ºc': //Get the actual selected unit type
              NewUnit = 'ºF'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat((SelectedUnitValue * 9 / 5) + 32).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'ºf': //Get the actual selected unit type
              NewUnit = 'ºC'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat((SelectedUnitValue - 32) * 5 / 9).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'ml': //Get the actual selected unit type
            case 'milliliter': //Get the actual selected unit type
            case 'milliliters': //Get the actual selected unit type
              NewUnit = 'fl oz (US)'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 29.574).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'fl oz (US)': //Get the actual selected unit type
            case 'fl oz': //Get the actual selected unit type
            case 'fl': //Get the actual selected unit type
            case 'fluid ounce': //Get the actual selected unit type
            case 'fluid ounces': //Get the actual selected unit type
              NewUnit = 'ml'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 29.574).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'l': //Get the actual selected unit type
            case 'litre': //Get the actual selected unit type
            case 'liter': //Get the actual selected unit type
            case 'litres': //Get the actual selected unit type
            case 'liters': //Get the actual selected unit type
              NewUnit = 'gal (US)'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 3.785).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'gal': //Get the actual selected unit type
            case 'gallon': //Get the actual selected unit type
            case 'gallons': //Get the actual selected unit type
              NewUnit = 'lt'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 3.785).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'yard': //Get the actual selected unit type
            case 'yards': //Get the actual selected unit type
            case 'yd': //Get the actual selected unit type
              NewUnit = 'm'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.094).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mm': //Get the actual selected unit type
            case 'millimetre': //Get the actual selected unit type
            case 'Millimeters': //Get the actual selected unit type
              NewUnit = 'in'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 25.4).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'ft': //Get the actual selected unit type
            case 'feet': //Get the actual selected unit type
            case 'feets': //Get the actual selected unit type
              NewUnit = 'mt'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 0.3048).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'kw': //Get the actual selected unit type
            case 'kws': //Get the actual selected unit type
            case 'kilowatt': //Get the actual selected unit type
            case 'kilowatts': //Get the actual selected unit type
              NewUnit = 'mhp'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 1.341).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mhp': //Get the actual selected unit type
            case 'mhps': //Get the actual selected unit type
            case 'hp': //Get the actual selected unit type
            case 'hps': //Get the actual selected unit type
            case 'brake horsepower': //Get the actual selected unit type
            case 'mechanical horsepower': //Get the actual selected unit type
              NewUnit = 'kw'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.341).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'mpg': //Get the actual selected unit type
            case 'mpgs': //Get the actual selected unit type
            case 'miles per gallon': //Get the actual selected unit type
            case 'miles per gallons': //Get the actual selected unit type
              NewUnit = 'l/100km'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(235.215 / SelectedUnitValue).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'l/100km': //Get the actual selected unit type
            case 'liters per 100 kilometer': //Get the actual selected unit type
            case 'liters per 100 kilometers': //Get the actual selected unit type
              NewUnit = 'US mpg'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(235.215 / SelectedUnitValue).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'lq': //Get the actual selected unit type
            case 'lqs': //Get the actual selected unit type
            case 'liquid quart': //Get the actual selected unit type
            case 'liquid quarts': //Get the actual selected unit type
              NewUnit = 'l'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.057).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'liter': //Get the actual selected unit type
            case 'liters': //Get the actual selected unit type
              NewUnit = 'lqs'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 1.057).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'foot-pound': //Get the actual selected unit type
            case 'foot-pounds': //Get the actual selected unit type
            case 'foot pound': //Get the actual selected unit type
            case 'foot pounds': //Get the actual selected unit type
            case 'ft-lbs': //Get the actual selected unit type
            case 'ft-lb': //Get the actual selected unit type
            case 'ft lbs': //Get the actual selected unit type
            case 'ft lb': //Get the actual selected unit type
            case 'lb ft': //Get the actual selected unit type
            case 'lb fts': //Get the actual selected unit type
              NewUnit = 'Nm'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue * 1.3558179483).toFixed(2); //Gets the converted unit result
              break; //Stop
            case 'newton-meter': //Get the actual selected unit type
            case 'newton-meters': //Get the actual selected unit type
            case 'newton meter': //Get the actual selected unit type
            case 'newton meters': //Get the actual selected unit type
            case 'nm': //Get the actual selected unit type
              NewUnit = 'ft lb'; //"Convert" the current unit to another unit
              ConvertedUnit = parseFloat(SelectedUnitValue / 1.3558179483).toFixed(2); //Gets the converted unit result
              break; //Stop
            case (SelectedText.match(Units)[2].replaceAll(',', '.').match(/\^/)).input: //Get the actual selected unit type
              NewUnit = 'power'; //"Convert" the current unit to another unit
              ConvertedUnit = Math.pow(parseFloat(SelectedUnitValue), parseFloat(SelectedText.split('^')[1])); //Gets the converted unit result
              break; //Stop
          } //Finishes the switch condition

          setTimeout(function() { //Starts the settimeout function
            document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = ConvertedUnit + ' ' + NewUnit + ' | '; //Display the converted unit results

            var text = document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText; //Save the actual converted unit value

            document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onmousemove = function() { //When the mouse is hovering the converted unit value
              document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = "Copy | "; //Change the element text to copy
            }; //Finishes the onmousemove event listener

            document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onmouseout = function() { //When the mouse leaves the button
              document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = text; //Return the previous text
            }; //Finishes the onmouseout event listener

            document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").onclick = function() { //When the user clicks on the converted unit value
              document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#ShowCurrencyORUnits").innerText = "Done | "; //Change the element text to copy
              navigator.clipboard.writeText(ConvertedUnit); //Copy the Final converted unit value
            }; //Finishes the onclick event listener
          }, 0); //Finishes the set timeout
        } //Finishes the if condition
      } //Finishes the if condition
      //___________________________________________________________________________________________________________________________________________________________________________
      if (document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#SearchBTN").innerText === 'Open') //If the Search button text is 'Open'
      { //Starts the if condition
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#highlight_menu > ul").style.paddingLeft = '7px'; //Change the ul menu element padding-left CSS style
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#SearchBTN").innerText = 'Search'; //The next time that the menu is shown display the button text as Search again
        SelectedTextIsLink = false; //Add the value false to the variable to make common words searchable again
      } //Finishes the if condition

      if (SelectedText.match(Links) !== null) //If the selected text is a link
      { //Starts the if condition
        SelectedTextIsLink = true; //Add the value true to the variable
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#highlight_menu > ul").style.paddingLeft = '7px'; //Change the ul menu element padding-left CSS style
        document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#SearchBTN").innerText = 'Open'; //Change the button text to Open
      } //Finishes the if condition
      //___________________________________________________________________________________________________________________________________________________________________________
      if (document.getSelection().toString().trim() !== '') { //If the user selected something
        var p = document.getSelection().getRangeAt(0).getBoundingClientRect(); //Create a new variable to get the positions later
        menu.css({ //Set the menu CSS
          left: (p.left + (p.width / 2)) - (menu.width() / 2), //Make the menu show on the correct left position
          top: (p.top - menu.height() - 10), //Make the menu show on the correct top position
          display: '' //Show the menu on the page
        }).animate({ //Creates the animation
          opacity: 1 //Set the animation opacity
        }, 0); //Add an animation to the menu

        menu.addClass('highlight_menu_animate'); //Add the class to animate the menu
        //$('head').append('<style>.highlight_menu_animate .popuptext::after { content: ""; top: 100%; left: 50%; margin-left: -10px; position: absolute; border-style: solid; border-color: #292929 transparent transparent transparent; }</style>'); //Create a class to animate the menu
        return; //Keep displaying the menu box
      } //Finishes the if condition
      menu.animate({ //Creates the animation
        opacity: 0 //Set the animation opacity
      }); //Hide the menu If the user clicks on any of the options

      setTimeout(function() { //Hide the menu after some time
        menu.css({ //Set the menu CSS
          display: 'none' //Hide the menu on the page
        }); //Hide the menu If the user clicks on any of the options
      }, 300); //Finishes the setTimeout function

    }); //Finishes the mouse up event listener
  }); //Finishes the function
  //___________________________________________________________________________________________________________________________________________________________________________
  var HtmlMenu = document.createElement('div'); //Creates a variable
  HtmlMenu.setAttribute("id", "highlight_menu_div"); //Set the div id to the HtmlMenu variable

  HtmlMenu.attachShadow({
    mode: 'open'
  }).innerHTML = '<style>.highlight_menu_animate .popuptext::after { content: ""; top: 100%; left: 50%; margin-left: -10px; border-top-width: 10px; border-right-width: 10px; border-left-width: 10px; position: absolute; border-style: solid; border-color: #292929 transparent transparent transparent; }</style><div id="highlight_menu" style="display:none; color: #fff; position: fixed; background-color: #292929; font-size: 13.4px; font-family: monospace; z-index: 9999;"> <ul style="margin-block-end: 10px; padding-left: 7px; padding-right: 7px; margin-top:10px;"><li class="popuptext" id="ShowCurrencyORUnits" style="cursor: pointer; display: inline;">' + FinalCurrency + '</li><li class="popuptext" id="SearchBTN" style="cursor: pointer; display: inline;">Search</li><li class="popuptext" id="CopyBTN" style="cursor: pointer; display: inline;"> | Copy</li></ul></div>'; //Set the HtmlMenu div html

  if (document.body.textContent !== '' || document.body.innerText !== '') //If the body has any text
  { //Starts the if condition
    document.body.appendChild(HtmlMenu); //Append the HtmlMenu div to the page
  } //Finishes the if condition

  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#SearchBTN").onmousedown = function() { //When the user clicks on the Search button
    var LinkfyOrSearch = 'https://www.google.com/search?q='; //Creates a variable to open google
    if (SelectedTextIsLink === true) //If the selected text is a link
    { //Starts the if condition
      LinkfyOrSearch = 'https://'; //Make the non-http and non-https links able to be opened
    } //Finishes the if condition
    if (SelectedText.match(/http:|https:/) !== null) //If the selected text is a link that already has http or https
    { //Starts the if condition
      LinkfyOrSearch = ''; //Remove the https:// that was previously added to this variable
    } //Finishes the if condition

    open(LinkfyOrSearch + SelectedTextSearch); //Open google and search for the selected word(s)
    getSelection().removeAllRanges(); //UnSelect the selected text after the search button is clicked so that if the user clicks on the past selected text the menu won't show up again.
    document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#highlight_menu").style.display = 'none'; //Hide the menu
  }; //Finishes the onmousedown event listener

  document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#CopyBTN").onmousedown = function() { //When the user clicks on the copy button
    navigator.clipboard.writeText(SelectedText); //Copy the selected word(s)
    document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#CopyBTN").innerText = ' | Done'; //Change the button text to Done
    setTimeout(function() { //Starts the setTimeout function
      document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#CopyBTN").innerText = ' | Copy'; //The next time that the menu is shown display the button text as Copy again, instead of Done
    }, 400); //Finishes the setTimeout function
  }; //Finishes the onmousedown event listener
  //___________________________________________________________________________________________________________________________________________________________________________
  setTimeout(function() { //Starts the setTimeout function
    var AllIframes = document.querySelectorAll("iframe"); //Get all iframes on the page
    for (var i = AllIframes.length; i--;) { //Starts the for condition
      if (AllIframes[i].allow.match('clipboard-write;') === null && AllIframes[i].src.match(Links) !== null && AllIframes[i].src.match(/recaptcha|challenges.cloudflare|youtube|dailymotion|vimeo|streamtape|mcloud|vidstream|mp4upload|googlevideo|kaltura|crunchyroll|animesup|google.com\/recaptcha\/|blank.html|mateus7g|\.mp4/) === null && location.href.match(/animeshouse.net|nowanimes.com\/play/) === null) //If the iframe doesn't have the clipboard-write attribute yet and the iframed source attribute has a link. And if the iframe isn't a YT/Dailymotion or Vimeo video.
      { //Starts the if condition
        AllIframes[i].allow = AllIframes[i].allow + 'clipboard-write;'; //Add the permission to copy the iframe text
        AllIframes[i].src = AllIframes[i].src; //Reload the iframe to make the iframe have the new permission
      } //Finishes the if condition
    } //Finishes the for condition
  }, 4000); //Finishes the setTimeout function

  window.addEventListener('scroll', async function() { //When the page is scrolled
    document.querySelector("#highlight_menu_div").shadowRoot.querySelector("#highlight_menu").style.display = 'none'; //Hide the menu
    if (LeftClicked === false && SelectedText !== '') { //If the Left Click isn't being held, and if something is currently selected
      getSelection().removeAllRanges(); //UnSelect the selected text when scrolling the page down so that if the user clicks on the past selected text the menu won't show up again.
    } //Finishes the if condition
  }); //Finishes the on-scroll event listener
} //Finishes the if condition