• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

A Rep-Identifying Bookmarklet

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    A Rep-Identifying Bookmarklet

    1. Copy the following (very long) line of code (a triple-click anywhere in the code box ought to select it all):

      (N.B. This is the new, more efficient version; the old version is left below for completeness.)

      Code:
      javascript:(function(){var memberURL, i, limit, reputationItem, userId, reputationList = document.getElementById("latest_reputation"),reputationItems = reputationList.getElementsByTagName("li"),connections = [],insertUsernameForId = function(element, id) {var connection;if (id in connections) { connection = connections[id];connection.elements[connection.elements.length] = element;} else {connection = connections[id] = {"http": new XMLHttpRequest(),"elements": [element]};memberURL = self.location.protocol + "//" + self.location.host + "/member.php/" + id;connection.http.open("GET", memberURL, true);connection.http.onreadystatechange = function(connection) {return function() {if (connection.http.readyState == 4) {var i, limit, elements, text = connection.http.responseText,username = /<title>View Profile: (.*) - Contractor UK Bulletin Board<\/title>/.exec(text)[1];for (i = 0, elements = connection.elements, limit = elements.length; i < limit; i++) {elements[i].appendChild(document.createElement("p")).appendChild(document.createElement("b")).appendChild(document.createTextNode("Repped by: " + username));}}};}(connection);connection.http.send("");}};for (i = 0; reputationItem = reputationItems[i]; i++) {userId = /[^_]\d*$/.exec(reputationItem.id)[0];insertUsernameForId(reputationItem, userId);}})()
      (N.B. This is the old version; use the one above instead, as it's more efficient, and also makes cooler use of closures, lambda calculus, partially applied functions, and stuff like that.)

      Code:
      javascript:(function() {var http, memberURL;var reputationList = document.getElementById("latest_reputation");var reputationItems = reputationList.getElementsByTagName("li");var t = [];var readystatechangeFactory = function(http, element, id) {return function() {if (http.readyState == 4) {var text = http.responseText;var userId = /<title>View Profile: (.*) - Contractor UK Bulletin Board<\/title>/.exec(text)[1];element.appendChild(document.createElement("p")).appendChild(document.createElement("b")).appendChild(document.createTextNode("Repped by: " + userId));}}};for (var i = 0, l = reputationItems.length, userId; i < l; i++) {http = new XMLHttpRequest();userId = /[^_]\d*$/.exec(reputationItems[i].id)[0];memberURL = self.location.protocol + "//" + self.location.host + "/member.php/" + userId;http.open("GET", memberURL, true);http.onreadystatechange = readystatechangeFactory(http, reputationItems[i], userId);http.send("");}})()
    2. Go to your settings page;

    3. Paste the code you just copied into your location bar;

    4. Hit Enter.


    Wait a few seconds for the code to fetch the data, and each of your reps will acquire an additional line giving the username of the person who awarded it

    You can turn that code into a bookmark on your bookmarks bar, for easy use in future, but the steps vary depending on browser; try having a look at the info in Wikipedia: Bookmarklet - Wikipedia, the free encyclopedia

    I'll post a neatly-formatted version of the code below for those who want to check out how it works - it's pretty trivial
    Last edited by NickFitz; 19 June 2011, 04:09.

    #2
    Readable version

    Old version is further below; this new version at the top ensures that only one HTTP request is made per userId, but all reps made by that user get updated together when the data flows back; the old version would make a new HTTP request for each line of rep.

    Code:
    var memberURL, i, limit, reputationItem, userId,
        reputationList = document.getElementById("latest_reputation"),
        reputationItems = reputationList.getElementsByTagName("li"),
        connections = [],
        insertUsernameForId = function(element, id) {
            var connection;
            if (id in connections) {
                connection = connections[id];
                connection.elements[connection.elements.length] = element;
            } else {
                connection = connections[id] = {
                    "http": new XMLHttpRequest(),
                    "elements": [element]
                };
                memberURL = self.location.protocol + "//" + self.location.host + "/member.php/" + id;
                connection.http.open("GET", memberURL, true);
                connection.http.onreadystatechange = function(connection) {
                    return function() {
                        if (connection.http.readyState == 4) {
                            var i, limit, elements, text = connection.http.responseText,
                            username = /<title>View Profile: (.*) - Contractor UK Bulletin Board<\/title>/.exec(text)[1];
                            for (i = 0, elements = connection.elements, limit = elements.length; i < limit; i++) {
                                elements[i].appendChild(document.createElement("p"))
                                    .appendChild(document.createElement("b"))
                                    .appendChild(document.createTextNode("Repped by: " + username));
                            }
                        }
                    };
                }(connection);
                connection.http.send("");
            }
        };
    for (i = 0; reputationItem = reputationItems[i]; i++) {
        userId = /[^_]\d*$/.exec(reputationItem.id)[0];
        insertUsernameForId(reputationItem, userId);
    }
    Older version, wears the server out:

    Code:
    var http, memberURL, i, limit,
        reputationList = document.getElementById("latest_reputation"),
        reputationItems = reputationList.getElementsByTagName("li"),
        readystatechangeFactory = function(http, element, id) {
            return function() {
                if (http.readyState == 4) {
                    var text = http.responseText;
                    var userId = /<title>View Profile: (.*) - Contractor UK Bulletin Board<\/title>/.exec(text)[1];
                    element.appendChild(document.createElement("p"))
                        .appendChild(document.createElement("b"))
                        .appendChild(document.createTextNode("Repped by: " + userId));
                   }
            }
        };
    for (i = 0, limit = reputationItems.length, userId; i < limit; i++) {
        http = new XMLHttpRequest();
        userId = /[^_]\d*$/.exec(reputationItems[i].id)[0];
        memberURL = self.location.protocol + "//" + self.location.host + "/member.php/" + userId;
        http.open("GET", memberURL, true);
        http.onreadystatechange = readystatechangeFactory(http, reputationItems[i], userId);
        http.send("");
    }
    Last edited by NickFitz; 19 June 2011, 04:08. Reason: Tidying

    Comment


      #3
      What happens in General, stays in General.
      You know what they say about assumptions!

      Comment


        #4
        Very good, but what happens if a post has been repped by multiple people?

        Comment


          #5
          Repping was supposed to be bit of fun but, sadly, a few insecure personae didn't get it.
          The shine has rather gone off the game.

          (The above comments are not meant as a criticism of you NF)
          +50 Xeno Geek Points
          Come back Toolpusher, scotspine, Voodooflux. Pogle
          As for the rest of you - DILLIGAF

          Purveyor of fine quality smut since 2005

          CUK Olympic University Challenge Champions 2010/2012

          Comment


            #6
            Originally posted by Zippy View Post
            Repping was supposed to be bit of fun but, sadly, a few insecure personae didn't get it.
            The shine has rather gone off the game.

            (The above comments are not meant as a criticism of you NF)
            Another piece of harmless CUK fun ruined by the boards equivalent of Domestos.
            What happens in General, stays in General.
            You know what they say about assumptions!

            Comment


              #7
              Originally posted by Gonzo View Post
              Very good, but what happens if a post has been repped by multiple people?
              Each award is shown separately; the same thread or post will appear multiple times if repped multiple times.

              Comment


                #8
                Originally posted by NickFitz View Post
                Each award is shown separately; the same thread or post will appear multiple times if repped multiple times.
                OK, if that ever happens to me I'll be able to check.

                Comment


                  #9
                  Originally posted by MarillionFan View Post
                  Another piece of harmless CUK fun ruined by the boards equivalent of Domestos.
                  I agree that you and a few other rep-whores ruined whatever trivial amount of fun the rep system might have offered by obsessing about it to the exclusion of anything else, but I'm not sure why this mea culpa necessitates comparing yourself to a cleaning product

                  Comment


                    #10
                    Not been able to keep up with the rep thing as the story unfolded but have managed to catch up. The names that have cropped up for being serial sneaky neg reppers are showing up for me. Churchill, EO, CM etc

                    I have been pretty honest about not using the neg rep and I cannot see anyone pulling me up for this but rather it is the pissy pants types like Churchill and EO who deny using the system for personal abuse that seem to be the serial abusers of the system and have been caught out.

                    Comment

                    Working...
                    X