11.02
I got a bit tired of not having user ignore possibility in smf 1.1.x series, and I found some scripts mostly for phpbb though there were some oldish hacks for smf too. I took one of those, and updated it to somehow match the 1.1.x series and newer GreaseMonkey (tested on 0.8.2…). Very simple to use, so no instructions needed :) Just change the line 27 to match you installation, this one is localized to match finnish language set.
Just save it to desktop like smf_userhide.user.js and open it with firefox with GreaseMonkey installed.
UPDATE: Just copy and paste the following snippet. It works okay, It’s just the WP-Syntax that seems to cut the lines. The whole content is copied anyway.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | // ==UserScript== // @name SMF User Hide // @include */index.php?topic=* // @description hides / unhides a user's posts - based on User Classes by Unarmed // @exclude // ==/UserScript== // Taken from // http://forums.mozillazine.org/viewtopic.php?f=19&t=236218&start=45, Authored // originally by Unarmed, Updated 2.11.2009 to match new GreaseMonkey and SMF // 1.1.4 by Juha Heimonen (function() { // Get stored hidden users from cookie var users = []; var cookieName = "smfUserHide"; for (var i = 0; i < document.cookie.split('; ').length; i++) { var oneCookie = document.cookie.split('; ')[i].split('='); if (oneCookie[0] == cookieName) { users = oneCookie[1].split(', '); break; } } // Find all the usernames in the page, to change to different locale, edit // this line to reflect that change var results = document.evaluate("//td/b/a[starts-with(@title, 'Tarkastele profiilia')]", document, null, XPathResult.ANY_TYPE, null); var resultNodes = []; var aResult; while (aResult = results.iterateNext()) { resultNodes.push(aResult); } // Loop through every user post on the page for (var i in resultNodes) { var containingRow = resultNodes[i].parentNode.parentNode.parentNode; // Format whitespace var user = encodeURI(resultNodes[i].innerHTML); // Flag whether the user is in our hide list var notFound = true; for (var j = 0; j < users.length; j++) { if (users[j] == user) { notFound = false; } } // Add relevant event handlers to a "[X]" node in front of user's name // On click, add or remove this user from the stored user list in the cookie var toggler = document.createElement('span'); toggler.title = "click to add or remove this user from your hide list"; toggler.appendChild(document.createTextNode('[X] ')); toggler.namenode = resultNodes[i]; toggler.addEventListener('mouseover',function(event) { event.target.style.cursor = 'pointer'; },true); toggler.addEventListener('mouseout',function(event) { event.target.style.cursor = 'pointer'; },true); toggler.style.fontSize = "7pt"; resultNodes[i].parentNode.insertBefore(toggler, resultNodes[i]); toggler.addEventListener('click',function(event) { for(j = 0; j < document.cookie.split('; ').length; j++ ) { var oneCookie = document.cookie.split('; ')[j].split('='); if (oneCookie[0] == cookieName) { users = oneCookie[1].split(', '); break; } } var tgt = event.target; / var user = encodeURI(resultNodes[i].innerHTML); notFound = true; for (var j = 0; j < users.length; j++) { if (users[j] == user) { users.splice(j, 1); notFound = false; } } if (notFound) users.push(user); if (users.length > 0) { var date = new Date(); var days = 365; date.setTime(date.getTime() + (days*24*60*60*1000)); var expires = '; expires=' + date.toGMTString(); var value = users.join(', '); document.cookie = cookieName + '=' + value + expires + '; path=/'; } else { document.cookie = cookieName + '=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'; } alert(decodeURI(user) + ' has been ' + (notFound ? 'added to' : 'removed from') + ' your hide list\n' + 'You must refresh the page to view the changes.'); },true); // If this user isn't in our hide list, skip to the next user if (notFound) continue; // Find the first element node in the containing row var elem = containingRow.firstChild; while (elem.nodeType != 1) elem = elem.nextSibling; // Create a span to control toggling var span = document.createElement('span'); span.appendChild(document.createTextNode('Toggle Display')); span.setAttribute('class', 'smalltext'); span.style.textDecoration = 'underline'; span.style.fontWeight = 'bold'; span.setAttribute('displaystate', 'none'); //span.onmouseover = function(event) { event.target.style.cursor = 'pointer'; }; span.addEventListener('mouseover',function(event) { event.target.style.cursor = 'pointer'; },true); //span.onmouseout = function(event) { event.target.style.cursor = 'default'; }; span.addEventListener('mouseout',function(event) { event.target.style.cursor = 'default'; },true); //span.onclick = function(event) { toggler.addEventListener('click',function(event) { var displayState = event.target.getAttribute('displaystate'); if (displayState == 'none') displayState = ''; else displayState = 'none'; event.target.setAttribute('displaystate', displayState); // Target user information elem = event.target.nextSibling; while (elem.nodeType != 1) elem = elem.nextSibling; if (elem.getAttribute && (elem.getAttribute('class') == 'smalltext')) elem.style.display = displayState; // Target post body elem = elem.parentNode.nextSibling; while (elem.nodeType != 1) elem = elem.nextSibling; if (elem.tagName.toUpperCase() == 'TD') elem.style.display = displayState; // Target post footer elem = elem.parentNode.nextSibling; while (elem.nodeType != 1) elem = elem.nextSibling; if (elem.tagName.toUpperCase() == 'TR') elem.style.display = displayState; },true); // Insert the span after the username and before the <br> elem.insertBefore(span, elem.firstChild.nextSibling.nextSibling); // Insert a <br> after the username and before the span elem.insertBefore(document.createElement('br'), elem.firstChild.nextSibling.nextSibling); // Crawl down and remove the postdetails span elem = elem.firstChild; while (elem) { if (elem.getAttribute && elem.tagName.toUpperCase() == 'DIV' && elem.getAttribute('class') == 'smalltext') elem.style.display = 'none'; elem = elem.nextSibling; } // Reset the elem pointer to the first table cell in the row elem = containingRow.firstChild; while (elem.nodeType != 1) elem = elem.nextSibling; // Move to the next table cell in the row elem = elem.nextSibling; while (elem.nodeType != 1) elem = elem.nextSibling; // Move inside that table cell and remove the postbody and postsig spans if (elem.tagName.toUpperCase() == 'TD') elem.style.display = 'none'; elem = elem.parentNode.nextSibling; while (elem.nodeType != 1) elem = elem.nextSibling; if (elem.tagName.toUpperCase() == 'TR') elem.style.display = 'none'; } })(); |