Last active
February 27, 2023 14:46
-
-
Save TangMonk/35ec5831d05b0a8f64a83ade2e1dd4e1 to your computer and use it in GitHub Desktop.
Uniswap Friendly Slippage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Unicrypt Slippage Notify | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://app.uniswap.org/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=uniswap.org | |
// @grant none | |
// ==/UserScript== | |
function getElementByXpath(path) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
(function () { | |
'use strict'; | |
setInterval(() => { | |
var sippage = JSON.parse(localStorage.getItem("redux_localstorage_simple_user")).userSlippageTolerance | |
var view = getElementByXpath(`//*[@id="swap-page"]/div[1]`) | |
var interval = setInterval(() => { | |
if (view == null) { | |
view = getElementByXpath(`//*[@id="swap-page"]/div[1]`) | |
} else { | |
var slippageElm = document.getElementById("slippageDiv") | |
if(slippageElm == null) { | |
slippageElm = document.createElement('div') | |
slippageElm.id = "slippageDiv" | |
} | |
sippage = sippage / 100 | |
if (sippage >= 5) { | |
slippageElm.style.color = "red" | |
slippageElm.innerText = `Slippage: ${sippage}% ⚠️⚠️` | |
}else{ | |
slippageElm.style.color = "rgb(119, 128, 160)" | |
slippageElm.innerText = `Slippage: ${sippage}%` | |
} | |
view.appendChild(slippageElm) | |
clearInterval(interval) | |
} | |
}, 100) | |
}, 100) | |
// Your code here... | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment