Help?
|
|
So I am really new to this and I am having a hard time figuring out how to do the following: I am a graphic designer for a company, and they have a page that lists the available projects. However, most of the time the page is empty and when there is something, people grab it pretty quickly. I don't like sitting on the computer all day, watching the screen refresh until a new project comes up, so in order to avoid that, I'd like to create a script that notifies me with a beep or ding or some sort of sound file that there is a project available. So far, I have managed to just create a js that refreshes the page for me every 90 seconds (I know, that's pretty easy and lame), but I cannot for the life of me find any help for playing a sound if a certain thing changes on the page... My idea was to have an alert noise play whenever the text "Showing 1 - 0 of" changes, because when there is a project, it will say something like "Showing 1 - 6 of" or similar, instead of "1 - 0", of course. Is this possible? Any ideas or help for me? Please? :) |
|
|
It's definitely possible. First make a GM_xmlhttpRequest to the page you're viewing, and create an array of the projects that exist currently. Then, set a window.setInterval (maybe every minute) to a function that makes another request to that page, makes another array, and compares it to the first array. If there is a new project found in the second array, the script should create an embed element with the source pointing to a sound file. It may seem pretty complex, but it really isn't; or at least I wouldn't think so. ways to play sound with javascript:
|
|
|
I think I'm hopelessly out of my depth here... I may just have to pay someone to build it for me. ;) I'm too new to this to even know how to write the functions you're talking about. |
|
|
RunningBlind said:
He's right. xmlhttpRequests can seem the most daunting of things to put together, but they can work out nicely once you just give it a go. If you've managed to write a script that refreshes at intervals, then it's clear you have at least some willingness to dive into code. The format for your request would look something like this:
GM_xmlhttpRequest({method:'GET',url:'http://www.company.org/projects.html',onload:function(response){
if(response.status==200){ // 200 means a success
var thePage = response.responseText;
// =========================== //
// == insert your code here == //
// =========================== //
}
});
Just have that occur at an interval, and compare the "thePage" variable to monitor whether it's changed. That's the most compicated part. If it's still too much for you, you could try posting a request in the "script ideas/requests" section of this forum. |
|
|
I think I will venture over to the requests section then. ;) Thanks for trying to help me though. I think I need to do some more learning on this. I thought knowing HTML would help me, but this is so different, I'm drowning. :D |
