Can someone update the reddit script to work with the new design?

tobwithu's picture

I uploaded new Reddit script.

Can you make it work on chrome?

jeroen's picture

@tobwithu: The old solution is still there...  (and working):

function getCount(aData) {
  var fnd=aData.match(/id="mail"/);
  if(fnd){
    fnd=aData.match(/<a .+? class="message-count" >(\d+)<\/a>/);
    return fnd?fnd[1]:0;
  }else return -1;
}

jeroen's picture

I didn't get there is a new design. So now I can see the getCount is correct for the new design. (But not for the old design)

jeroen's picture

I will have a closer look at the script. Most time it keeps hanging while checking (I got the correct behavior and count one time). Perhaps something is missing in the login procedure... Strange, because clicking the account confirms that login session is established. 

Thx, I hope you find a way to make it work.

jeroen's picture

I wasn't able to solve the login. Perhaps tobwithu(s) can do the job... 
I suspect it needs an extra information exchange with the server (probably by using an AJAX call).

The present script works one time after the script has logged in successfully. You can verify this by going to the X-notifier options and uncheck the checkmark in front of your reddit account (then Save). Then logout manually from your reddit account and after waiting a while check the checbox again  (and Save). You will probably see this works, but on second Check Now it will hang forever and/or turn red.

For a half-way solution I added the checkLogin function, which makes it possible to login manually (correctly) and skip the incomplete login of the script: it will only extract the unread count from the html. My script version should do this for both old and new design (html). Of course you then need to login again when a login essential cookie expires.

jeroen's picture

You can download it here:  reddit Script
(Left click and download using the button that will appear at top-right next to the Share button)