Last active
February 21, 2019 09:52
-
-
Save karlosos/f10073d562193fe120ba to your computer and use it in GitHub Desktop.
timo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Timocom | |
// @namespace timocom | |
// @description timocom | |
// @include https://my.timocom.com/app/tco/freight/search/ | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var button = "<button id=\"refresher\" aria-label=\"automatyczne odświeżanie\" aria-disabled=\"false\" role=\"button\" id=\"app:cnt:freightSearchForm:autorefreshBtn\" name=\"app:cnt:freightSearchForm:autorefreshBtn\" type=\"button\" class=\"ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only\" title=\"automatyczne odświeżanie [Ctrl+Alt+u]\" onclick=\"TC.tco.focusStack.push(this); return false;;window.location.href='/app/tco/freight/search/index.xhtml';\"><span class=\"ui-button-icon-left ui-icon tc-icon-intern tc-ticker-09\"></span><span class=\"ui-button-text\"> </span><div class=\"tc-accessKeyInfo tc-accessKeyContext-STANDARD\">u</div><span class=\"tc-ticker-point tc-ticker-point-01\" style=\"display:none;\"></span></button>"; | |
var enabled = false; | |
var count = 0; | |
document.addEventListener('DOMContentLoaded', function () { | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
}); | |
var checker = function() { | |
if (enabled) { | |
if ($('.c100').first().html() == "Nie znaleziono wyników - zmień kryteria wyszukiwania." || count == 0) { | |
console.log("Szukam dalej"); | |
} | |
else { | |
enabler(); | |
enabled = false; | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification('TIMOCOM', { | |
icon: 'http://kumiec.pl/wp-content/uploads/2013/07/Timocom.png', | |
body: "Nowe wyniki wyszukiwania!", | |
}); | |
notification.onclick=function() { | |
try | |
{ | |
window.focus(); | |
} | |
catch (ex) {}; | |
}; | |
} | |
} | |
} | |
}; | |
var enabler = function() { | |
enabled = !enabled; | |
if (enabled) { | |
$("#refresher span").css("background-color", "red"); | |
count = 0; | |
} else { | |
$("#refresher span").css("background-color", "green"); | |
count = 0; | |
} | |
}; | |
var refresher = setInterval(function() { | |
console.log("Count: " + String(count)); | |
if (count > 150) { | |
enabler(); | |
} | |
if(enabled) { | |
if ($('.c100').first().html() == "Nie znaleziono wyników - zmień kryteria wyszukiwania." || count == 0) { | |
console.log("szukam dalej"); | |
enabled = true; | |
count++; | |
} else { | |
enabler(); | |
enabled = false; | |
// if (!Notification) { | |
// alert('Desktop notifications not available in your browser. Try Chromium.'); | |
// return; | |
// } | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification('TIMOCOM', { | |
icon: 'http://kumiec.pl/wp-content/uploads/2013/07/Timocom.png', | |
body: "Nowe wyniki wyszukiwania!", | |
}); | |
notification.onclick=function() { | |
try | |
{ | |
window.focus(); | |
} | |
catch (ex) {}; | |
}; | |
} | |
} | |
} | |
if (enabled){ | |
console.log("refresh instance"); | |
//freightSearchForm.CtrlBtns.autorefreshBtn.manuallyRefresh(); | |
//freightSearchForm.resetChangeMark(); | |
PrimeFaces.ab({ | |
source: 'app:cnt:freightSearchForm:searchBtn', | |
process: 'app:cnt:freightSearchForm', | |
update: 'app:cnt:messages', | |
oncomplete: function(xhr, status, args) { | |
freightSearchForm.CtrlBtns.searchBtn.stop(); | |
} | |
}); | |
setTimeout(checker, 1000); | |
} else { | |
console.log("nie enabled"); | |
} | |
}, 5000); | |
console.log("Zaladowano skrypt"); | |
$('.ui-toolbar').append(button); | |
$("#refresher span").click(enabler); | |
$("#refresher span").css("background-color", "green"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Timocom | |
// @namespace timocom | |
// @description timocom | |
// @include https://my.timocom.com/app/tco/freight/search/ | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var button = "<button id=\"refresher\" aria-label=\"automatyczne odświeżanie\" aria-disabled=\"false\" role=\"button\" id=\"app:cnt:freightSearchForm:autorefreshBtn\" name=\"app:cnt:freightSearchForm:autorefreshBtn\" type=\"button\" class=\"ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only\" title=\"automatyczne odświeżanie [Ctrl+Alt+u]\" onclick=\"TC.tco.focusStack.push(this); enabler(); return false;;window.location.href='/app/tco/freight/search/index.xhtml';\"><span class=\"ui-button-icon-left ui-icon tc-icon-intern tc-ticker-09\"></span><span class=\"ui-button-text\"> </span><div class=\"tc-accessKeyInfo tc-accessKeyContext-STANDARD\">u</div><span class=\"tc-ticker-point tc-ticker-point-01\" style=\"display:none;\"></span></button>"; | |
var enabled = false; | |
var count = 0; | |
document.addEventListener('DOMContentLoaded', function () { | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
}); | |
unsafeWindow.checker = function() { | |
if (enabled) { | |
if ($('.c100').first().html() == "Nie znaleziono wyników - zmień kryteria wyszukiwania." || count == 0) { | |
console.log("Szukam dalej") | |
} | |
else { | |
enabler(); | |
enabled = false; | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification('TIMOCOM', { | |
icon: 'http://kumiec.pl/wp-content/uploads/2013/07/Timocom.png', | |
body: "Nowe wyniki wyszukiwania!", | |
}); | |
notification.onclick=function() { | |
try | |
{ | |
window.focus(); | |
} | |
catch (ex) {}; | |
}; | |
} | |
} | |
} | |
}; | |
unsafeWindow.enabler = function() { | |
enabled = !enabled; | |
if (enabled) { | |
$("#refresher span").css("background-color", "red"); | |
count = 0; | |
} else { | |
$("#refresher span").css("background-color", "green"); | |
count = 0; | |
} | |
}; | |
var refresher = setInterval(function() { | |
console.log("Count: " + String(count)); | |
if (count > 150) { | |
enabler(); | |
} | |
if(enabled) { | |
if ($('.c100').first().html() == "Nie znaleziono wyników - zmień kryteria wyszukiwania." || count == 0) { | |
console.log("szukam dalej"); | |
enabled = true; | |
count++; | |
} else { | |
enabler(); | |
enabled = false; | |
// if (!Notification) { | |
// alert('Desktop notifications not available in your browser. Try Chromium.'); | |
// return; | |
// } | |
if (Notification.permission !== "granted") | |
Notification.requestPermission(); | |
else { | |
var notification = new Notification('TIMOCOM', { | |
icon: 'http://kumiec.pl/wp-content/uploads/2013/07/Timocom.png', | |
body: "Nowe wyniki wyszukiwania!", | |
}); | |
notification.onclick=function() { | |
try | |
{ | |
window.focus(); | |
} | |
catch (ex) {}; | |
}; | |
} | |
} | |
} | |
if (enabled){ | |
console.log("refresh instance"); | |
//freightSearchForm.CtrlBtns.autorefreshBtn.manuallyRefresh(); | |
//freightSearchForm.resetChangeMark(); | |
PrimeFaces.ab({ | |
source: 'app:cnt:freightSearchForm:searchBtn', | |
process: 'app:cnt:freightSearchForm', | |
update: 'app:cnt:messages', | |
oncomplete: function(xhr, status, args) { | |
freightSearchForm.CtrlBtns.searchBtn.stop(); | |
} | |
}); | |
setTimeout(checker, 1000); | |
} else { | |
console.log("nie enabled"); | |
} | |
}, 5000); | |
console.log("Zaladowano skrypt"); | |
$('.ui-toolbar').append(button); | |
$("#refresher span").css("background-color", "green"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment