Advertisement
Guest User

ESR AJAX Plus v2

a guest
Aug 9th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          ESR AJAX Plus
  3. // @namespace     http://www.esreality.com/
  4. // @version       2.0
  5. // @description   "Plus" posts without reloading the page!
  6. // @include       http://www.esreality.com/*
  7. // @require       http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
  8. // ==/UserScript==
  9.  
  10. $('a[title^="Click [+]"]').each(function(i, item) {
  11.   var $self = $(this);
  12.   $self.click(function() {
  13.     var href = $self.attr('href');
  14.     var post_id = parseInt(href.match(/post_id=(\d+)/)[1]);
  15.     $.ajax({url: href, dataType: 'html'}).success(function(html) {
  16.       var selector = 'a[class="judgementvalue"][href$="post_id=' + post_id + '"]'
  17.         , $jv = $(selector);
  18.       if ($jv.length) {
  19.         $jv.html($(selector, html).html());
  20.       } else {
  21.         $self.before($(selector, html), " ");
  22.       }
  23.     }).error(function() {
  24.       alert('Something went wrong, sorry :/');
  25.     })
  26.     return false;
  27.   });
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement