4 Replies Latest reply: Apr 30, 2006 5:54 PM by 807597 RSS

    Ignore user feature

    807597
      After sun tweaked the forum UI, the "ignore user" greasemonkey script someone was kind enough to post here no longer works in thread.jspa
      and it seems sun still have not provided this functionality in these forums.

      I would have resurrected the old thread, but although I can find it (here) I cannot access it.

      I rely quite a bit on the script to cut the chaff from the wheat - unfortunately I never got around to greasemonkey script coding.
      Maybe one of the kind posters involved in customizing the script for these forums would post an update?
      I can post the script source I have been using these last 6 months.
        • 1. Re: Ignore user feature
          800345
          That was me who posted the script. I am rarely on these days, and upgraded my computer so I don't have that script around anymore. If you post it / a link to it I will re-visit it to see why it isn't working.

          My guess is that the name of the <div> tag used to mark where the user's post is received a name change. Or one of the other <div>s I use as sign posts to locate the posts where changed.
          • 2. Re: Ignore user feature
            807597
            The original:
            // ==UserScript==
            // @name         Jive User Hide
            // @include      */thread.jspa*
            // @include      */forum.jspa*
            // @include      */category.jspa*
            // @description  Hides/unhides a user's posts
            // @exclude
            // ==/UserScript==
             
            (function() {
                 // Get stored hidden users from cookie
                 var users = [];
                 var cookieName = "jiveUserHide";
                 for (var i = 0; i < document.cookie.split('; ').length; i++) {
                      var oneCookie = document.cookie.split('; ').split('=');
                      if (oneCookie[0] == cookieName) {
                           users = oneCookie[1].split(', ');
                           break;
                      }
                 }

                 // Cursor functions
                 var curPointer = function(event) {
                      event.target.style.cursor = 'pointer';
                      event.preventDefault();
                 };
                 var curDefault = function(event) {
                      event.target.style.cursor = 'default';
                      event.preventDefault();
                 };

                 // Add or remove a user from the cookie
                 var addRemoveUser = function(event) {
                      // Parse current cookie
                      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 user = escape(event.target.nextSibling.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=/';
                      }
                      window.alert(unescape(user) + ' has been ' + (notFound ? 'added to' : 'removed from')
                           + ' your hide list\n'
                           + 'You must refresh the page to view the changes.');
                      event.preventDefault();
                 };
                 // Toggle display of user's post
                 var togglePost = function(event) {
                      var displayState = event.target.getAttribute('displaystate');
                      if (displayState == 'none')
                           displayState = '';
                      else
                           displayState = 'none';
                      event.target.setAttribute('displaystate', displayState);

                      containingRow = event.target.parentNode.parentNode;
                      var innerTags = containingRow.getElementsByTagName('*');
                      for (var i = 0; i < innerTags.length; i++) {
                           var tagClass = innerTags[i].getAttribute('class');
                           if (tagClass == 'dkcaption1' || tagClass == 'pad10x0')
                                innerTags[i].style.display = displayState;
                      }
                      event.preventDefault();
                 };
                 
                 var sPath = window.location.pathname;     
                 var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
                 
                 if (sPage == 'thread.jspa') { // we're in a thread
                 
                      // Find all the usernames in the page
                      var results = document.evaluate("//span[@class='dkcaption1']/a", 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.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
                           // Format whitespace
                           var user = escape(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 user's name and a toggler node
                           var toggler = document.createElement('span');
                           toggler.setAttribute('title', "click to add or remove this user from your hide list");
                           toggler.appendChild(document.createTextNode('[X] '));
                           toggler.style.fontSize = "7pt";
                           toggler.addEventListener('mouseover', curPointer, true);
                           toggler.addEventListener('mouseout', curDefault, true);
                           toggler.addEventListener('click', addRemoveUser, true);

                           resultNodes[i].parentNode.insertBefore(toggler, resultNodes[i]);

                           // If this user isn't in our hide list, skip to the next user
                           if (notFound)
                                continue;

                           // Find the first element node (td) 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.appendChild(document.createElement('br'));
                           span.setAttribute('class', 'gensmallbold');
                           span.style.textDecoration = 'underline';
                           span.setAttribute('displaystate', 'none');
                           span.addEventListener('mouseover', curPointer, true);
                           span.addEventListener('mouseout', curDefault, true);
                           span.addEventListener('click', togglePost, 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);

                           var innerTags = containingRow.getElementsByTagName('*');
                           for (var i = 0; i < innerTags.length; i++) {
                                var tagClass = innerTags[i].getAttribute('class');
                                if (tagClass == 'dkcaption1' || tagClass == 'pad10x0')
                                     innerTags[i].style.display = 'none';
                           }
                      }     
                      
                 } else { // we're in the forum list page
                 
                      // Find all the usernames in the page
                      var results = document.evaluate("//div[@class='pad3x5']/a", 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 = escape(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 user's name and a toggler node
                           var toggler = document.createElement('span');
                           toggler.setAttribute('title', "click to add or remove this user from your hide list");
                           toggler.appendChild(document.createTextNode('[X] '));
                           toggler.style.fontSize = "7pt";
                           toggler.addEventListener('mouseover', curPointer, true);
                           toggler.addEventListener('mouseout', curDefault, true);
                           toggler.addEventListener('click', addRemoveUser, true);

                           resultNodes[i].parentNode.insertBefore(toggler, resultNodes[i]);

                           // If this user isn't in our hide list, skip to the next user
                           if (notFound)
                                continue;                    

                           var innerTags = containingRow.getElementsByTagName('*');
                           for (var i = 0; i < innerTags.length; i++) {
                                var tagClass = innerTags[i].getAttribute('class');
                                if (tagClass == 'pad3x0' || tagClass == 'pad3x5')
                                     innerTags[i].style.display = 'none';
                           }
                      }               
                 
                 }
            })();
            • 3. Re: Ignore user feature
              800345
              That's a different one then the one I posted, it has more functionality and stores the users in a cookie (which is nice since GM won't let us read from local files using GM_xmlHttpRequest anymore).

              I will look into that one too to see if I can find the change.
              • 4. Re: Ignore user feature
                807597
                That's a different one then the one I posted
                I thought it was Yogee rather than you. Maybe I'm not quite going senile yet after all.