We have online issue tracker (web-site). Issues comes periodically and we need some application or maybe script which can observe page for ul's li elements and if one of them is new notify about it.
So I have tried to use FireFox GreaseMonkey script and it works fine, but not enough: we have an issue type which need following actions:
1) check issue's additional file name/date
2) click on link "More" inside issue and open new window with the list of files
3) in this second window I need to find link and notify user with attached link
so I need to pass file name/date as parameters from main page to the second page to get the right link
Unfortunately there is no possibility to use another more comfortable issue tracker, so guys extremely need help ))
// ==UserScript==
// @name none
// @namespace none.rw
// @version 1
// @grant none
// ==/UserScript==
var mainSleepSeconds = 1;
var timerId;
(function(){
// Start the script
document.addEventListener('keydown', function(e) {
// pressed ctrl+shift+s to start
if (e.ctrlKey && e.shiftKey && e.keyCode == 83 && !e.altKey && !e.metaKey) {
unsafeWindow.console.log("Start observer...");
timerId = setInterval(main, mainSleepSeconds*1000);
}
// pressed ctrl+shift+q to stop
if (e.ctrlKey && e.shiftKey && e.keyCode == 81 && !e.altKey && !e.metaKey) {
unsafeWindow.console.log("Stop!");
clearInterval(timerId);
}
}, false);
var leftList
function main() {
unsafeWindow.console.log("main");
// checking leftList is presents
if (leftList == 'undefined' || leftList == null) {
leftList = typeof document.getElementById("leftList") != 'undefined'
? document.getElementById("leftList") : null;
}
if (leftList != null) {
// getting <ul> under "scroller"
var scrollerUl = document.getElementById("arScroll")
.getElementsByClassName("scroller")[0]
.getElementsByTagName("ul")[0];
// getting list of <li>
var list = scrollerUl.getElementsByTagName("li");
for (var i=0; i < list.length; i++) {
if (list[i].className.indexOf("issue_") !== -1) {
//here if issue type 1 then send ajax (works)
//
//if issue type 2 - find elements "f-name", "f-date",
//"More"
//and open link inside "More" in separate tab passing two parameters from "f-name", "f-date".
}
}
}
}
// this also not works (((
function openInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
}
)();
Aucun commentaire:
Enregistrer un commentaire