pte_etr_pack.user.js
Summary
No overview generated for 'pte_etr_pack.user.js'
var EtrPack = function ()
{
var instance = this;
var countMsg = null;
var msgLink = null;
var newMsgLink = null;
var originalMsgLinkText = null;
var msgIframe = null;
var msgDelButtons = new Array();
var msgDelCheckboxes = new Array();
var msgTable = null;
var countDeletedMsg = 0;
this.msgLinkPattern = "Önnek ([0-9]+) új webes üzenete érkezett!";
this.file = "";
this.PHPGET = new Array();
this.parseQuery = function(query)
{
var _GET = new Array();
if (query)
{
query = query.split('&');
for(var i in query)
{
var tmp = query[i].split('=');
_GET[tmp[0]] = tmp.slice(1).join('=');
}
}
return _GET;
}
this.setUrl = function()
{
var a = window.location.href.split('#');
var f = a[0].substr(a[0].lastIndexOf('/')+1);
var qsa = f.split('?');
instance.file = qsa[0];
var query = (a.length > 1) ? a[1] : '';
instance.PHPGET = instance.parseQuery(qsa.slice(1).join('?'));
}
this.setUrl();
this.getMsgLink = function()
{
if (msgLink == null)
{
var links = document.getElementsByTagName('a');
var msgLinkRegexp = new RegExp(instance.msgLinkPattern);
for (var i in links )
{
if(msgLinkRegexp.exec(links[i].innerHTML))
{
msgLink = links[i];
break;
}
}
}
return msgLink;
}
this.getCountMsg = function()
{
if (countMsg == null)
{
countMsg = new RegExp("[0-9]+").exec(originalMsgLinkText);
}
return countMsg;
}
this.createMsgIframe = function()
{
var iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '300px';
iframe.style.display = GM_getValue('msg_iframe_display');
iframe.src = 'Uzenet_lista.aspx';
return iframe;
}
this.getMsgIframe = function ()
{
if (msgIframe == null)
{
msgIframe = instance.createMsgIframe();
}
return msgIframe;
}
this.getNewMsgLink = function()
{
if (newMsgLink == null)
{
var newMsgLink = document.createElement('a');
newMsgLink.innerHTML = instance.getCountMsg() + " új üzenet megjelenítése";
newMsgLink.href = "javascript:;";
newMsgLink.id = "newMsgLink";
newMsgLink.addEventListener('click',function(event)
{
var msgIframe = instance.getMsgIframe();
msgIframe.style.display = (msgIframe.style.display == 'none') ? 'block' : 'none';
GM_setValue('msg_iframe_display',msgIframe.style.display);
},true);
}
return newMsgLink;
}
this.msgLinkToMsgIframe = function()
{
var msgLink = instance.getMsgLink();
if (msgLink == null)
{
return;
}
var slash = document.createElement('span');
slash.innerHTML = " / ";
slash.style.fontWeight = "bold";
originalMsgLinkText = msgLink.innerHTML;
msgLink.innerHTML = "megnyitása";
msgLink.parentNode.insertBefore(instance.getNewMsgLink(),msgLink);
msgLink.parentNode.insertBefore(slash, msgLink);
msgLink.parentNode.appendChild(instance.getMsgIframe());
}
this.deleteMsg = function(_url)
{
GM_xmlhttpRequest({
method: "GET",
url: "https://www.tr.pte.hu"+_url,
onload: function (response)
{
countDeletedMsg++;
}
});
}
this.actionButtonToCheckbox = function()
{
var imgs = document.getElementsByTagName('img');
var k = 0;
for (var i in imgs)
{
if (imgs[i].className == 'actionbutton')
{
msgDelButtons[k] = imgs[i];
var msgDelCheckbox = document.createElement('input');
msgDelCheckbox.value = "0";
msgDelCheckbox.type = "checkbox";
msgDelCheckboxes[k++] = msgDelCheckbox;
imgs[i].style.display = "none";
imgs[i].parentNode.appendChild(msgDelCheckbox);
}
}
if (k > 0)
{
var table = msgDelButtons[0].parentNode.parentNode.parentNode.parentNode;
msgTable = table;
var cells = table.rows[0].cells;
var cell = cells[cells.length-1];
var chbAllChecked = document.createElement('input');
chbAllChecked.type = 'checkbox';
chbAllChecked.addEventListener('click', function (event) {
for(var i in msgDelCheckboxes)
{
msgDelCheckboxes[i].checked = chbAllChecked.checked;
}
},true);
var msgDelButton = document.createElement('input');
msgDelButton.type = 'button';
msgDelButton.value = 'Kijelöltek törlése';
msgDelButton.style.marginLeft = '20px';
msgDelButton.style.height = '20px';
msgDelButton.addEventListener('click',function() {
var regexp = new RegExp("location\\.replace\\('(.*)'\\)");
if (!confirm('Biztosan törlöd a kijelölt üzeneteket?'))
{
return;
}
var k=0;
for (var i in msgDelCheckboxes)
{
if (msgDelCheckboxes[i].checked)
{
var url = regexp.exec(msgDelButtons[i].parentNode.innerHTML)[1].replace('&','&');
instance.deleteMsg(url);
k++;
}
}
var interval = setInterval(function(){
if (countDeletedMsg >= k)
{
clearInterval(interval);
if (window.parent)
{
window.parent.location.reload();
}
}
},1000);
},true);
table = document.getElementsByTagName('table')[1];
table.rows[0].cells[0].appendChild(msgDelButton);
cell.innerHTML = "";
cell.appendChild(chbAllChecked);
}
}
this.sortMsg = function()
{
GM_xmlhttpRequest({
method: "POST",
url: 'https://www.tr.pte.hu/etr/Uzenet_lista.aspx',
data: 'UZENET_Lista_sort=@send_date&UZENET_Lista_sortdir=desc&UZENET_Lista_sorttipus=text',
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
}
}
var ep = new ClassEtrPack();
switch (ep.file.toLowerCase())
{
case 'uzenet_lista.aspx':
ep.actionButtonToCheckbox();
break;
case 'default.aspx':
if (GM_getValue('login') == '1')
{
ep.sortMsg();
GM_setValue('login','0');
window.location.reload();
}
ep.msgLinkToMsgIframe();
break;
case 'login.aspx':
GM_setValue('msg_iframe_display','none');
GM_setValue('login','1');
break;
}
Documentation generated by
JSDoc on Mon Nov 2 19:07:47 2009