Site Search:
 
Speak Korean Now!
Teach English Abroad and Get Paid to see the World!
Korean Job Discussion Forums Forum Index Korean Job Discussion Forums
"The Internet's Meeting Place for ESL/EFL Teachers from Around the World!"
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Blocking User

 
Post new topic   Reply to topic    Korean Job Discussion Forums Forum Index -> Off-Topic Forum
View previous topic :: View next topic  
Author Message
2i2dk1ny2i3



Joined: 26 Jun 2011

PostPosted: Wed Jul 13, 2011 4:27 am    Post subject: Blocking User Reply with quote

http://www.dmitryvolokhov.info/daves-esl-cafe-discussion-forums-automatically-block-specified-users/


anyone know if there's a version for Opera?

i really prefer Opera > Firefox but will give Firefox a try if i must
Back to top
View user's profile Send private message
Pangit



Joined: 02 Sep 2004
Location: Puet mo.

PostPosted: Wed Jul 13, 2011 5:02 am    Post subject: Reply with quote

Opera can use greasemonkey scripts. Here's directions how to use javascript in Opera - http://my.opera.com/Contrid/blog/2007/02/11/how-to-greasemonkey-in-opera

I suggest you use this, though:
Code:
(function() {
    // Get stored hidden users from cookie
    var users = [];
    var cookieName = "phpUserHide";
    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;
       }
    }

    // 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 == 'postbody' || tagClass == 'postsig'
             || tagClass == 'postdetails' || innerTags[i].tagName == 'TABLE')
             innerTags[i].style.display = displayState;
       }
       event.preventDefault();
    };
    // Toggle display of user's quote
    var toggleQuote = function(event) {
       var displayState = event.target.getAttribute('displaystate');
       if (displayState == 'none')
          displayState = 'table-row';
       else
          displayState = 'none';
       event.target.setAttribute('displaystate', displayState);

       // Jump to parent row
       var containingRow = event.target.parentNode.parentNode.parentNode.parentNode.nextSibling;
       // Find containing row
       while (containingRow.nodeType != 1)
          containingRow = containingRow.nextSibling;
       containingRow.style.display = displayState;

       event.preventDefault();
    };

    // Find all the usernames in the page
    var results = document.evaluate("//span[@class='name']/b|//span[@class='name']/strong", 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;

       // 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 == 'postbody' || tagClass == 'postsig'
             || tagClass == 'postdetails' || innerTags[i].tagName == 'TABLE')
             innerTags[i].style.display = 'none';
       }
    }

    // Find all the usernames quoted in the page
    var results = document.evaluate("//td[@class='quote']/parent::*/preceding-sibling::*/td/span/b|"
       + "//td[@class='quote']/parent::*/preceding-sibling::*/td/span/strong", document, null,
       XPathResult.ANY_TYPE, null);
    var resultNodes = [];
    var aResult;
    while (aResult = results.iterateNext())
       resultNodes.push(aResult);

    // Loop through every user quote on the page
    for (var i in resultNodes) {
       var containingRow = resultNodes[i].parentNode.parentNode.parentNode.nextSibling;
       while (containingRow.nodeType != 1)
          containingRow = containingRow.nextSibling;

       // Find username
       var usermatch = resultNodes[i].innerHTML.match(/(.*) wrote:$/);
       if (usermatch)
          var user = escape(usermatch[1]);
       else
          continue;

       // 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;
          }
       }

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

       // Create a span to control toggling
       var span = document.createElement('span');
       span.appendChild(document.createElement('br'));
       span.appendChild(document.createTextNode('Toggle Display'));
       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', toggleQuote, true);

       resultNodes[i].appendChild(span);
       
       // Hide the quote
       containingRow.style.display = 'none';
    }

 })();


Copy the text, open notepad, save it to a file named whatever.user.js in the folder you directed Opera to for JavaScript.

I tried using Dimitry's script, but it was throwing up errors.
Back to top
View user's profile Send private message
2i2dk1ny2i3



Joined: 26 Jun 2011

PostPosted: Wed Jul 13, 2011 8:47 pm    Post subject: Reply with quote

thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Korean Job Discussion Forums Forum Index -> Off-Topic Forum All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


This page is maintained by the one and only Dave Sperling.
Contact Dave's ESL Cafe
Copyright © 2018 Dave Sperling. All Rights Reserved.

Powered by phpBB © 2001, 2002 phpBB Group

TEFL International Supports Dave's ESL Cafe
TEFL Courses, TESOL Course, English Teaching Jobs - TEFL International