Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Userscript 

PM Notifications - Checks for new PMs every 60 seconds!

Hello again

I made this userscript in a few minutes. I thought it was a good idea to be honest.

What it does is when you visit a page, it will check if you get a new PM every 60 seconds. If you get a new PM, it will ask you if you want to read the PM.
However, if you are typing, it will simply tell you that you got a new message (you can accidentally press redirect if you're typing).

IF YOU ARE TYPING
[Image: 9fs2E.png]

IF YOU ARE NOT TYPING
[Image: 9fs4v.png]
(Annuller means Cancel)

For Firefox get GreaseMonkey.
For Chrome get TamperMonkey.
For other browsers: Get Chrome.

Go add a new script and put this code into the script:

PHP Code

<?php 
// ==UserScript==
// @name      Hack Forums PM Notifications
// @namespace      Snorlax
// @description     Notifies you when you receive a new PM
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @grant      GM_getValue
// @grant      GM_setValue
// @grant      GM_openInTab
// @include      *hackforums.net/*
// @version      1.0
// ==/UserScript==

function run() {
    $.
get("upgrade.php", function(data) {
      if($(
data).find("strong:contains('unread private message')").length) {
      
message = $(data).find("strong:contains('unread private message')").text();
      
username = $(data).find("strong:contains('unread private message')").next().text();
      
messageURL = $(data).find("strong:contains('unread private message')").next().next().attr("href");
      
regex = /You have (.*?) unread private message/;
      match = 
regex.exec(message);
      if(match[
1] == "one") {
      match[
1] = "1";
      }
      if(match[
1] > GM_getValue("messages")) {
      if (
confirm('You got a new message from: ' + username + '\nDisplay it now?')) {
      
GM_openInTab("https://hackforums.net/" + messageURL);
      }
      }
      
message = match[1];
      } else {
      
message = 0;
      }
      
GM_setValue("messages", message);
    });
    
console.log("Amount of messages: " + GM_getValue("messages"));
}
setInterval(function() {
    
run();
}, 
60000); 

I chose upgrade.php because it requires basically no resources. That means less load on the server and faster response for you!

Report any bugs and please give me some feedback here! Thanks :)
I can confirm this works. Great user script snorlax <3.
(Jun 4, 2014 05:08 PM)ℳanny Wrote:  I can confirm this works. Great user script snorlax ♥.

Whoa you're fast haha. Thanks a lot! I love making this stuff for you guys.
I can also confirm that this works. Keep up the good work 'Snorlax!
Great script as usual. For a few minutes, you're really fast!


(Jun 4, 2014 05:10 PM)_wind Wrote:  Great script as usual. For a few minutes, you're really fast!

Haha yep! I think the whole thing through in my head, and then I basically just do it. TALENTS 🤣

Thanks, Roger :3
Do you think you can make this so that it displays a chrome notification instead? (Like the one you get when you receive an email in chrome?) That way it's less intrusive.
[Image: wOdD4yf.gif]
(Jun 4, 2014 05:11 PM)Pillows Wrote:  Do you think you can make this so that it displays a chrome notification instead? (Like the one you get when you receive an email in chrome?) That way it's less intrusive.

Dude I tried so hard to make it work. Literally spent like 2 hours trying to find various scripts and make it work. That was my first intention, but I haven't been able to find a way.
Since it's an userscript, the user have to press a button (YES.. PRESS) to make it ask for permissions to create desktop notifications. And even with that it didn't work...
(Jun 4, 2014 05:16 PM)xadamxk Wrote:  So many userscripts in one day, oh muy gosh D:

I KNOW RIGHT. It's the best day of my life :')
Nah jk. My head is sore from coding like 6 hours straight.
This looks great and also works great!
PLEASE THANK 1n9i9c7om! He told me about GM_openInTab which allows me to open a message in a new tab. JUST what I needed!

Update your userscript with my newly updated one and it will open in a new tab instead!
(Jun 6, 2014 01:34 PM)'Snorlax Wrote:  PLEASE THANK 1n9i9c7om! He told me about GM_openInTab which allows me to open a message in a new tab. JUST what I needed!

Update your userscript with my newly updated one and it will open in a new tab instead!

Huh.... no problem, luckily we randomly came up with the topic userscripts xD


Possibly Related Threads...
Thread / Author Replies Views Last Post
by XeroticJul 31, 2017 10:51 PM 231 10,394 Jul 31, 2017 10:51 PM
Last Post: Steve
[Userscript] by Raymond ReddingtonOct 8, 2016 02:16 AM 7 304 Oct 8, 2016 02:16 AM
Last Post: Captain Steve Rogers
[Chrome] by ZuGgYApr 15, 2015 09:24 PM 1 113 Apr 15, 2015 09:24 PM
Last Post: NoScript