NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Hide Voted Posts on Steem // @namespace http://tampermonkey.net/ // @version 2.0 // @description Hide already voted posts on SteemIt.com // @author netuoso // @match https://steemit.com/* // @grant WTFPL // ==/UserScript== function hideVotedPosts() { // Get all posts votes count var elements = document.getElementsByClassName("VotesAndComments__votes"); // Loop over the posts and hide the entire post if there are votes // 0 votes has title of "no votes" for (var i=0; i<elements.length; i++) { var votes = elements[i].getAttribute('title'); if (votes !== "no votes") { elements[i].parentElement.parentElement.parentElement.parentElement.parentElement.style.display="none"; } } } function showVotedPosts() { // Get all posts var elements = document.getElementsByClassName("PostSummary"); var footerElements = document.getElementsByClassName("PostSummary__footer"); // Loop over the posts and unhide them for (var i=0; i<elements.length; i++) { elements[i].parentElement.style.display="list-item"; footerElements[i].style.display = "list-item"; } } function toggleAutoFilter(setting) { if (setting == "enable" ) { hideVotedPosts(); document.getElementById("enableFilterLink").style.display = "none"; document.getElementById("disableFilterLink").style.display = "inline-block"; // Enable auto filtering document.getElementsByClassName("PostsList__summaries")[0].addEventListener("DOMNodeInserted", function(event) { hideVotedPosts(); }); } else { showVotedPosts(); document.getElementById("disableFilterLink").style.display = "none"; document.getElementById("enableFilterLink").style.display = "inline-block"; // Disable auto filtering // Enable auto filtering document.getElementsByClassName("PostsList__summaries")[0].addEventListener("DOMNodeInserted", function(event) { showVotedPosts(); }); } } /*--- Note, gmMain () will fire under all these conditions: 1) The page initially loads or does an HTML reload (F5, etc.). 2) The scheme, host, or port change. These all cause the browser to load a fresh page. 3) AJAX changes the URL (even if it does not trigger a new HTML load). */ var fireOnHashChangesToo = true; var pageURLCheckTimer = setInterval ( function () { if ( this.lastPathStr !== location.pathname || this.lastQueryStr !== location.search || (fireOnHashChangesToo && this.lastHashStr !== location.hash) ) { this.lastPathStr = location.pathname; this.lastQueryStr = location.search; this.lastHashStr = location.hash; gmMain (); } }, 111 ); function gmMain () { // Create a button called "Hide Voted Posts" var enableWrapper = document.createElement("li"); enableWrapper.id = "enableFilterLink"; enableWrapper.className = "votedScript"; var enableLink = document.createElement("a"); enableLink.innerHTML = "hide voted posts"; enableLink.onclick = function() { toggleAutoFilter("enable"); }; enableLink.style.pointer = "cursor"; enableWrapper.appendChild(enableLink); // Create a button called "Hide Voted Posts" var disableWrapper = document.createElement("li"); disableWrapper.id = "disableFilterLink"; disableWrapper.className = "votedScript"; var disableLink = document.createElement("a"); disableLink.innerHTML = "show voted posts"; disableLink.onclick = function() { toggleAutoFilter("disable"); }; disableLink.style.pointer = "cursor"; disableWrapper.appendChild(disableLink); disableWrapper.style.display = "none"; try { // Append the link to the navigation bar on the top of the screen if (window.location.href.indexOf("created") > 0) { if (document.getElementsByClassName("votedScript").length === 0) { // Append the link to the navigation bar on the top of the screen document.getElementsByClassName('HorizontalMenu')[0].appendChild(enableWrapper); document.getElementsByClassName('HorizontalMenu')[0].appendChild(disableWrapper); } else { document.getElementsByClassName("votedScript")[0].style.display = "inline-block"; } } else { if (document.getElementsByClassName("votedScript").length > 0) { for (i=0;document.getElementsByClassName("votedScript").length;i++) { document.getElementsByClassName("votedScript")[i].style.display = "none"; } } } } catch (e) {} }