Per-thread "Mark as read" button



  • The title says it all: turn you Greasemonkey on and give this a try. Your search experience will improve by 0.012%.

    (Copy and paste the script in a local foobar.user.js file, then open it with Firefox -- Greasemonkey will install it).

    Any HELP is appreciated! Feedbacks are welcome too :)

    http://pastebin.com/icBP3DxB

    (I'm not putting the code here because the forum software breaks due to the "@" symbols inside ... :( )



  • Here we go :-)

    @
    // ==UserScript==
    // @name Qt Developer Network - Mark Thread As Read
    // @namespace developer.qt.nokia.com/markasread
    // @description Adds a button to mark posts as read without having to open them.
    // @match http://developer.qt.nokia.com/forums/search_results/*
    // @match https://developer.qt.nokia.com/forums/search_results/*
    // @version 0.11
    // ==/UserScript==

    $ = unsafeWindow.jQuery;

    $('.forum_main_wrap').each(function(i) {
    var row = $(this);
    var threadUrl = $('a', row).attr('href');

    var button = $('<button>Mark as read</button>')
                  .addClass('jqueryui-button')
                  .css('white-space', 'nowrap');
    
    var buttonDiv = $('<div></div>')
                     .addClass('forum_main_right mark_as_read')
                     .append(button)
                     .hide();
                     
    button.click(function() {
        $(this).attr('disabled', 'disabled');
        $.ajax({
            url: threadUrl,
            cache: false,
            success: function(html) {
                row.fadeOut('fast');
            }
        });
    });
    
    row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
    row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
    
    $('.forum_main_body', row).before(buttonDiv);
    

    });
    @



  • Well, thanks for the tip :) Now I know that I have to HTML-escape them :)



  • Here you go with a bit advanced version:

    @
    // ==UserScript==
    // @name Qt Developer Network - Mark Thread As Read
    // @namespace developer.qt.nokia.com/markasread
    // @description Adds a button to mark posts as read without having to open them.
    // @match http://developer.qt.nokia.com/forums/search_results/*
    // @match https://developer.qt.nokia.com/forums/search_results/*
    // @version 0.12
    // ==/UserScript==

    $ = unsafeWindow.jQuery;

    $('.forum_main_wrap').each(function(i) {
    var row = $(this);
    var threadUrl = $('a', row).attr('href');
    var cssObj = {
    'padding' : '4px 8px!important',
    '-moz-border-radius' : '5px 5px 5px 5px',
    'border-radius' : '5px 5px 5px 5px',
    'white-space' : 'nowrap',
    // 'margin-bottom' : '10px',
    // 'padding' : '3px 4px'
    'padding' : '1px 1px'
    }

    var button = $('<button>Mark as read</button>')
                  .css(cssObj);
    
    var buttonDiv = $('<div></div>')
                     .addClass('forum_main_right mark_as_read')
                     .append(button)
                     .hide();
                     
    button.click(function() {
        $(this).attr('disabled', 'disabled');
        $.ajax({
            url: threadUrl,
            cache: false,
            success: function(html) {
                row.fadeOut('fast');
            }
        });
    });
    
    row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
    row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
    
    $('.forum_main_body', row).before(buttonDiv);
    

    });
    @



  • Updated version for the 19 Jan 2012 upgrade that broke the button's style
    @
    // ==UserScript==
    // @name Qt Developer Network - Mark Thread As Read
    // @namespace developer.qt.nokia.com/markasread
    // @description Adds a button to mark posts as read without having to open them.
    // @match http://developer.qt.nokia.com/forums/search_results/*
    // @match https://developer.qt.nokia.com/forums/search_results/*
    // @version 0.13
    // ==/UserScript==

    $ = unsafeWindow.jQuery;

    $('.forum_main_wrap').each(function(i) {
    var row = $(this);
    var threadUrl = $('a', row).attr('href');
    var cssObj = {
    'padding' : '4px 8px!important',
    '-moz-border-radius' : '5px 5px 5px 5px',
    'border-radius' : '5px 5px 5px 5px',
    'white-space' : 'nowrap',
    // 'margin-bottom' : '10px',
    // 'padding' : '3px 4px'
    'padding' : '1px 1px'
    }

    var button = $('<button>Mark as read</button>')
                  .css(cssObj)
                  .addClass('qtcdk button');
    
    var buttonDiv = $('<div></div>')
                     .addClass('forum_main_right')
                     .append(button)
                     .hide();
                      
    button.click(function() {
        $(this).attr('disabled', 'disabled');
        $.ajax({
            url: threadUrl,
            cache: false,
            success: function(html) {
                row.fadeOut('fast');
            }
        });
    });
    
    row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
    row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
     
    $('.forum_main_body', row).before(buttonDiv);
    

    });
    @



  • @
    // ==UserScript==
    // @name Qt Developer Network - Mark Thread As Read
    // @namespace developer.qt.nokia.com/markasread
    // @description Adds a button to mark posts as read without having to open them.
    // @match http://qt-project.org/forums/search_results/*
    // @match https://qt-project.org/forums/search_results/*
    // @match http://qt-project.org/forums/viewforum/*
    // @match https://qt-project.org/forums/viewforum/*
    // @version 0.14
    // ==/UserScript==

    $ = unsafeWindow.jQuery;

    $('.forum_main_wrap').each(function(i) {
    var row = $(this);
    var threadUrl = $('a', row).attr('href');
    var cssObj = {
    'padding' : '4px 8px!important',
    '-moz-border-radius' : '5px 5px 5px 5px',
    'border-radius' : '5px 5px 5px 5px',
    'white-space' : 'nowrap',
    // 'margin-bottom' : '10px',
    // 'padding' : '3px 4px'
    'padding' : '1px 1px'
    }

    var button = $('<button>Mark as read</button>')
                  .css(cssObj)
                  .addClass('qtcdk button');
    
    var buttonDiv = $('<div></div>')
                     .addClass('forum_main_right')
                     .append(button)
                     .hide();
                      
    button.click(function() {
        $(this).attr('disabled', 'disabled');
        $.ajax({
            url: threadUrl,
            cache: false,
            success: function(html) {
                row.fadeOut('fast');
            }
        });
    });
    
    row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
    row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
     
    $('.forum_main_body', row).before(buttonDiv);
    

    });
    @


  • Moderators

    Thank you peppe for the script.

    The first post refers to FireFox. However, it is also usable with Chrome (tested on windows).
    Check for GreaseMonkey on addon page. You will not find GreaseMonkey, but a substitute called TamperMonkey. You may basically copy the script as provided here in there. The only "challenge" are the 'at' signs. They are visible here, are hex codes when you copy the script code. Use the editor and replace them with 'at' signs.



  • It works quite well on FF, I'm impressed!
    Thanks a bunch, it solves one of the issues I "posted":/forums/viewthread/15920 earlier today.



  • New version... I promise I'll put it somewhere so that GM can update it automatically. :-)

    @
    // ==UserScript==
    // @name Qt Developer Network - Mark Thread As Read
    // @namespace developer.qt.nokia.com/markasread
    // @description Adds a button to mark posts as read without having to open them.
    // @match http://qt-project.org/forums/search_results/*
    // @match https://qt-project.org/forums/search_results/*
    // @match http://qt-project.org/forums/viewforum/*
    // @match https://qt-project.org/forums/viewforum/*
    // @version 0.15
    // ==/UserScript==

    $ = unsafeWindow.jQuery;

    $('.forum_main_wrap').each(function(i) {
    var row = $(this);
    var threadUrl = $('a', row).attr('href');
    var cssObj = {
    'padding' : '4px 8px!important',
    '-moz-border-radius' : '5px 5px 5px 5px',
    'border-radius' : '5px 5px 5px 5px',
    'white-space' : 'nowrap',
    // 'margin-bottom' : '10px',
    // 'padding' : '3px 4px'
    'padding' : '1px 1px',
    'position': 'absolute'
    }

    var button = $('<button>Mark as read</button>')
                  .css(cssObj)
                  .addClass('qtcdk button');
    
    var buttonDiv = $('<div></div>')
                     .addClass('forum_main_right')
                     .css('position', 'relative')
                     .append(button)
                     .hide();
                      
    button.click(function() {
        $(this).attr('disabled', 'disabled');
        $.ajax({
            url: threadUrl,
            cache: false,
            success: function(html) {
                row.fadeOut('fast');
            }
        });
    });
    
    row.mouseenter(function() { buttonDiv.fadeIn('fast'); });
    row.mouseleave(function() { buttonDiv.fadeOut('fast'); });
     
    $('.forum_main_body', row).before(buttonDiv);
    

    });
    @



  • Change is that now the rows don't change height as often any more, making the DevNet a bit easier on the eyes again. Thanks a bunch!



  • [quote author="koahnig" date="1333121898"]Thank you peppe for the script.

    The first post refers to FireFox. However, it is also usable with Chrome (tested on windows).
    Check for GreaseMonkey on addon page. You will not find GreaseMonkey, but a substitute called TamperMonkey. You may basically copy the script as provided here in there. The only "challenge" are the 'at' signs. They are visible here, are hex codes when you copy the script code. Use the editor and replace them with 'at' signs. [/quote]

    Yes, that's the downside of the textile markup... However, I think you can just copy and paste from the forum directly? It seems to work for me here (Firefox 11).



  • I've just released a chrome extension with this and some more functionality to the google webstore. See the "announcement here":/forums/viewthread/16100.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.