Skip to content

Instantly share code, notes, and snippets.

@jmhdez
Last active August 13, 2023 01:16
Show Gist options
  • Save jmhdez/6405474 to your computer and use it in GitHub Desktop.
Save jmhdez/6405474 to your computer and use it in GitHub Desktop.
Javascript console replacement
(function(window, document) {
// Create the DOM structure to hold the console messages
var div = document.createElement("div");
div.style.cssText = "position: absolute; " +
"top: 5px; left: 5px; right: 5px; bottom: 5px; " +
"padding: 10px; " +
"overflow-y: auto; " +
"display: none; " +
"background: rgba(0, 32, 0, 0.9); " +
"border: 3px solid #888; " +
"font: 14px Consolas,Monaco,Monospace; " +
"color: #ddd; " +
"z-index: 500";
var ul = document.createElement("ul");
ul.style.cssText = "padding: 0; list-style-type: none; margin: 0";
div.appendChild(ul)
document.body.appendChild(div);
var toggleButton = document.createElement("button");
toggleButton.innerText = "Console";
toggleButton.style.cssText = "position: absolute; right: 10px; top: 10px; z-index: 501";
toggleButton.addEventListener("click", function () {
div.style.display = div.style.display === "none" ? "block" : "none";
});
document.body.appendChild(toggleButton);
var clearButton = document.createElement("button");
clearButton.innerText = "Clear";
clearButton.style.cssText = "position: absolute; right: 10px; top: 30px; z-index: 501";
clearButton.addEventListener("click", function() {
ul.innerHTML = "";
});
div.appendChild(clearButton);
function addMsg(msg) {
var li = document.createElement("li");
li.innerText = msg;
ul.appendChild(li);
}
// Monkey-patch console object
var methods = ["log", "debug", "error", "info", "warn"];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
var original = window.console[method];
window.console[method] = function(msg) {
addMsg(msg);
original.apply(window.console, arguments);
};
}
})(window, document);
@ZulyMaressa
Copy link

setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
  }
  window.scrollTo(0, document.body.scrollHeight)
}, 1000)

@Topexaranda06
Copy link

<script src="https://gist.github.com/jmhdez/6405474/raw/8f4bdbb07b58eef2834ef72a66bdd56902e58419/console.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment