Advertisement
Guest User

Untitled

a guest
Dec 7th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          Qt Developer Network - Mark Thread As Read
  3. // @namespace     developer.qt.nokia.com/markasread
  4. // @description   Adds a button to mark posts as read without having to open them.
  5. // @match         http://developer.qt.nokia.com/forums/search_results/*
  6. // @match         https://developer.qt.nokia.com/forums/search_results/*
  7. // @version       0.11
  8. // ==/UserScript==
  9.  
  10. $ = unsafeWindow.jQuery;
  11.  
  12. $('.forum_main_wrap').each(function(i) {
  13.     var row = $(this);
  14.     var threadUrl = $('a', row).attr('href');
  15.  
  16.     var button = $('<button>Mark as read</button>')
  17.                   .addClass('jqueryui-button')
  18.                   .css('white-space', 'nowrap');
  19.  
  20.     var buttonDiv = $('<div></div>')
  21.                      .addClass('forum_main_right mark_as_read')
  22.                      .append(button)
  23.                      .hide();
  24.                      
  25.     button.click(function() {
  26.         $(this).attr('disabled', 'disabled');
  27.         $.ajax({
  28.             url: threadUrl,
  29.             cache: false,
  30.             success: function(html) {
  31.                 row.fadeOut('fast');
  32.             }
  33.         });
  34.     });
  35.  
  36.     row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
  37.     row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
  38.    
  39.     $('.forum_main_body', row).before(buttonDiv);
  40. });
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement