From 0893316b684dc2c0612f4bf4ebedd0bd9db9db0c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 Nov 2021 14:53:57 -0500 Subject: [PATCH] Added script to refresh any ME page. --- javascript/MagicEden-MarketRefresh.js | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 javascript/MagicEden-MarketRefresh.js diff --git a/javascript/MagicEden-MarketRefresh.js b/javascript/MagicEden-MarketRefresh.js new file mode 100644 index 0000000..bfd5fe4 --- /dev/null +++ b/javascript/MagicEden-MarketRefresh.js @@ -0,0 +1,69 @@ +// ==UserScript== +// @name MagicEden Auto-Refresh +// @namespace http://tampermonkey.net/ +// @version 1.0.4 +// @description Press Q to Auto-refresh +// @author NFTHoarder (original DapperDucks script) & WTMike24 (reduced for any other ME page) +// @match https://magiceden.io/marketplace/* +// @match https://www.magiceden.io/marketplace/* +// @exclude https://magiceden.io/marketplace/dapper_ducks +// @icon https://www.google.com/s2/favicons?domain=moonrank.app +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + window.AutoRefresh = 0; + window.OpacityBoolean = 1; + + var i = document.createElement('iframe'); + i.style.display = 'none'; + document.body.appendChild(i); + window.console = i.contentWindow.console; + + var script = document.createElement('script'); + script.src = 'https://code.jquery.com/jquery-3.4.1.min.js'; + script.type = 'text/javascript'; + document.getElementsByTagName('head')[0].appendChild(script); + setTimeout(function() { + const newDiv = document.createElement("div"); + newDiv.setAttribute("id", "jquery_loaded"); + const currentDiv = document.getElementById("root"); + document.body.insertBefore(newDiv, currentDiv); + }, 1000); + + (new MutationObserver(checkForJquery)).observe(document, {childList: true, subtree: true}); + + function checkForJquery(changes, observer) { + if(document.querySelector('#jquery_loaded')) { + observer.disconnect(); + var oldFetch = fetch; + $('#root').css({ background: "black"}); + $('body').keydown(function (e){ + console.log(e.keyCode); + if(e.keyCode == 81){ + toggleAutoRefresh(); + } + }); + setInterval(function() { + autoRefresh(); + }, 5000); + } + } + + function autoRefresh() { + $(".d-flex").css({ display: "flex"}); + //$(".pt-2").css({ padding: ".5rem"}); + if(window.AutoRefresh == 1) { + $(".me-refresh-btn")[0].click() + } + } + + function toggleAutoRefresh() { + if(window.AutoRefresh == 0) { + window.AutoRefresh = 1; + } else { + window.AutoRefresh = 0; + } + } +})();