By Yehuda B.
—
Last update
Jul 4, 2008
—
Installed
2,040 times.
// Orange IL user script
// version 0.5
// 2008-07-04
// Copyright (c) 2007, Yehuda B.
// Released under the Creative Commons Attribution-NonCommercial-ShareAlike license
// http://creativecommons.org/licenses/by-nc-sa/3.0/
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey/Creammonkey user script.
// For Firefox you will need to install
// Greasemonkey 0.6.6 or later: https://addons.mozilla.org/firefox/748/
// Then restart your browser and revisit this script.
// Accept the default configuration and install.
//
// To uninstall from Firefox go to Tools/Manage User Scripts,
// select "Orange IL", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Orange IL
// @namespace http://yehudab.com
// @description Fix display issues and SMS sending in Orange Israel (Cellular provider)
// @include http://www.orange.co.il/obox/sendsms.aspx*
// @include http://www.orange.co.il/obox/PB*
// @include http://orange.co.il/obox/sendsms.aspx*
// @include http://orange.co.il/obox/PB*
// @include http://www.orange.co.il/orange.mergelogin/pages/login.aspx*
// ==/UserScript==
var uWindow;
if (typeof unsafeWindow == 'undefined')
uWindow = window;
else
uWindow = unsafeWindow;
fixButtons();
if (window.location.href.match(/\/sendsms.aspx/i))
fixSMS();
if (window.location.href.match(/\/login.aspx/i))
fixLogin();
function fixLogin()
{
GM_log("fixLogin")
if (document.getElementById('sm_USER').value != "")
{
document.getElementById('sm_SMENC').value='Windows-1255';
document.getElementById('ctl00_mainContentPlaceHolder_btnSubmit').click();
}
}
function fixSMS()
{
var acceptedcharsEN = new RegExp("^[ -~\r\n]*$");
var acceptedchars = new RegExp("^[\u05D0-\u05EA\u0410-\u044F]*$");
var acceptedcharsLTR = new RegExp("^[ -~\r\n\u0410-\u044F]*$");
var maxlengthEN = 160;
var maxlength = 70;
uWindow.IsEnglishOnly = function(textRef, CurrChar) {
var cCurrText = textRef.value + CurrChar;
if (cCurrText.match(acceptedcharsEN))
return true;
else
return false;
}
IsLTR = function(textRef) {
var cCurrText = textRef.value;
if (cCurrText.match(acceptedcharsLTR))
return true;
else
return false;
}
uWindow.IsValidChar = function (textRef, CurrChar, key) {
if (key==13)
return true;
if (CurrChar.match(acceptedcharsEN) || CurrChar.match(acceptedchars))
{
return true;
}
else
{
return false;
}
}
uWindow.IsValidLength = function(textRef, CurrChar) {
var nMaxSize = (uWindow.IsEnglishOnly(textRef, CurrChar)) ? maxlengthEN : maxlength;
return (nMaxSize - (textRef.value + CurrChar).length)
}
uWindow.validateTyping = function(textRef, e) {
var key;
if (window.event) key = window.event.keyCode;
else if (e) key = e.which;
else return false;
// alert(key);
if (key==0 || key==8)
return true;
if ((key==null) || (key==9) || (key==27) || (key==35))
return false;
var keychar = String.fromCharCode(key);
//alert(key);
return uWindow.IsValidChar(textRef, keychar, key) && (uWindow.IsValidLength(textRef, keychar) >= 0);
}
uWindow.SetCounterText = function(textRef, counterRef) {
var cLangDir;
var nMaxSize;
if(uWindow.IsEnglishOnly(textRef, ""))
{
nMaxSize = maxlengthEN;
}
else
{
nMaxSize = maxlength;
}
if(IsLTR(textRef))
{
cLangDir = "ltr";
}
else
{
cLangDir = "rtl";
}
counterRef.innerHTML = (nMaxSize - textRef.value.length);
textRef.dir = cLangDir;
}
uWindow.unSelClick = function(objRef, myid) {
//alert(objRef.checked);
//alert(document.all.msisdn_list.value.split(',').length);
//if(document.all.msisdn_list.value.split(',').length < 3)
//{
var Form1 = objRef.form;
var unselectArray = eval("objRef.form." + objRef.name);
var cHtmlData = "";
var bgColors = new Array("FFFFFF", "F3F3F3");
//var bgColors = new Array("F3F3F3", "FFFFFF");
var bgColorsCounter = 0;
var count = 0;
for (var i=0; i<unselectArray.length; i++) {
if (unselectArray[i].checked && !uWindow.IsGroup(unselectArray[i]))
count++;
}
if (uWindow.IsGroup(objRef))
{
if(count - 1 + uWindow.CountUncheckedinGroup(objRef, unselectArray) < Form1.count_field.value || !objRef.checked || Form1.count_field.value == -1)
{
uWindow.groupClick(objRef, unselectArray);
count = 0;
for (var i=0; i<unselectArray.length; i++) {
if (unselectArray[i].checked && !uWindow.IsGroup(unselectArray[i]))
count++;
}
}
else
{
var message = "\u05db\u05de\u05d5\u05ea \u05de\u05e1\u05e4\u05e8\u05d9\u05dd \u05de\u05d5\u05d2\u05d1\u05dc\u05ea \u05dc - "/*"ÛÞÕê ÞáäèÙÝ ÞÕÒÑÜê Ü - "*/ + Form1.count_field.value + " \u05dc\u05d0 \u05e0\u05d9\u05ea\u05df \u05dc\u05d1\u05d7\u05d5\u05e8 \u05d9\u05d5\u05ea\u05e8 \u05de\u05e1\u05e4\u05e8\u05d9\u05dd ";//" ÜÐ àÙêß ÜÑ×Õè ÙÕêè ÞáäèÙÝ "
objRef.checked = false;
document.getElementById('lblNumberError').innerHTML= message;
document.getElementById('lblNumberError').style.display= 'block';
}
}
//alert(count);
if(count - 1 < Form1.count_field.value || !objRef.checked || Form1.count_field.value == -1)
{
if(typeof(unselectArray.length) == 'undefined')
{
if(flag == 'empty')
{
cHtmlData
+= "<tr bgcolor=#" + bgColors[++bgColorsCounter%2] + ">"
+ "<td width=10><input type=checkbox name=selItem id=" + myid + " value=" + gl_msisdn + " onClick=selClick(this); checked></td>"
+ "<td id=freetext>" + gl_msisdn + "</td>"
+ "</tr>";
flag = 'filled';
}
else
{
cHtmlData = '';
flag = 'empty';
}
}
else
{
for (var i=0; i<unselectArray.length; i++) {
if (unselectArray[i].checked && !uWindow.IsGroup(unselectArray[i]))
cHtmlData
+= "<tr bgcolor=#" + bgColors[++bgColorsCounter%2] + ">"
+ "<td width=10><input type=checkbox name=selItem id=" + unselectArray[i].id + " value=" + unselectArray[i].value + " onClick=selClick(this); checked></td>"
+ "<td id=freetext>" + unselectArray[i].parentNode.parentNode.cells[1].innerHTML + "</td>"
+ "</tr>";
}
}
cHtmlData
= "<table width=170 id=selList border=0 dir=rtl cellpadding=1 cellspacing=1>"
+ cHtmlData
+ "</table>";
// document.getElementById("selList").outerHTML = cHtmlData;
var selList = document.getElementById("selList");
var r = selList.ownerDocument.createRange();
r.setStartBefore(selList);
var df = r.createContextualFragment(cHtmlData);
selList.parentNode.replaceChild(df, selList);
if (objRef.checked)
uWindow.SelectGroup(unselectArray);
else
uWindow.UnselectGroup(unselectArray);
uWindow.InitLists();
}
else
{
var message = "\u05db\u05de\u05d5\u05ea \u05de\u05e1\u05e4\u05e8\u05d9\u05dd \u05de\u05d5\u05d2\u05d1\u05dc\u05ea \u05dc - "/*"ÛÞÕê ÞáäèÙÝ ÞÕÒÑÜê Ü - "*/ + Form1.count_field.value + " \u05dc\u05d0 \u05e0\u05d9\u05ea\u05df \u05dc\u05d1\u05d7\u05d5\u05e8 \u05d9\u05d5\u05ea\u05e8 \u05de\u05e1\u05e4\u05e8\u05d9\u05dd ";//" ÜÐ àÙêß ÜÑ×Õè ÙÕêè ÞáäèÙÝ "
objRef.checked = false;
document.getElementById('lblNumberError').innerHTML= message;
document.getElementById('lblNumberError').style.display= 'block';
}
}
uWindow.CheckFreeMSISDN_ALL = function(freeTextRef, unselectArray, tableRef) {
if (freeTextRef.value == "")
return;
var bFound = false;
//alert(freeTextRef.getAttribute('maxlength'));
var pattern;
switch(freeTextRef.getAttribute('maxlength')-0)
{
case 7:
pattern = new RegExp("\\d{7}");
break;
case 10:
pattern = new RegExp("[0][5]\\d{8}");
break;
}
var result;
if(!(result=pattern.test(freeTextRef.value)))
{
document.getElementById('lblNumberError').innerHTML= "\u05de\u05e1\u05e4\u05e8 \u05d0\u05d9\u05e0\u05d5 \u05d7\u05d5\u05e7\u05d9!"; //'Þáäè ÐÙàÕ ×ÕçÙ!';
document.getElementById('lblNumberError').style.display= 'block';
freeTextRef.value = "";
freeTextRef.focus();
return;
}
gl_msisdn = freeTextRef.value + "";
if (gl_msisdn.length == 7)
gl_msisdn = gl_msisdn;
for (var i=0; i<unselectArray.length; i++)
if (!uWindow.IsGroup(unselectArray[i]) && uWindow.GetMSISDN(unselectArray[i]) == gl_msisdn)
{
if (!unselectArray[i].checked)
unselectArray[i].click();
bFound = true;
}
if (!bFound)
{
var bgColors = new Array("#F3F3F3", "#FFFFFF");
var newRowRef = tableRef.insertRow(-1);
newRowRef.bgColor = bgColors[tableRef.rows.length % 2];
var newCellRef = newRowRef.insertCell(-1);
newCellRef.width = 10;
newCellRef.innerHTML = "<input type=checkbox name=unselItem id=_A00" + tableRef.rows.length + " value=\"|" + gl_msisdn + "\" onClick=\"unSelClick(this, _A00" + tableRef.rows.length + ");\">";
newCellRef = newRowRef.insertCell(-1);
newCellRef.id = "freetext";
newCellRef.innerHTML = gl_msisdn;
unselectArray[unselectArray.length-1].click();
}
freeTextRef.value = "";
}
uWindow.InitLists = function() {
/////////////////////// contacts
var selectArray = document.getElementsByName("selItem");
if (selectArray == null || selectArray.length == 0)
return;
//var aliasArray = document.getElementsByName("freeAlias");
//alert(document.all.selList.childNodes[0].childNodes.length);
var entity_list = document.getElementsByName("entity_list")[0];
var msisdn_list = document.getElementsByName("msisdn_list")[0];
var alias_list = document.getElementsByName("alias_list")[0];
var selList = document.getElementById("selList");
entity_list.value = "";
msisdn_list.value = "";
alias_list.value = "";
// try
// {
var trArray = selList.childNodes[0].childNodes;
for (var i=0; i<trArray.length; i++)
{
//alert(trArray[i].childNodes[1].innerHTML);
if (alias_list.value != "")
alias_list.value += ", ";
alias_list.value += trArray[i].childNodes[1].innerHTML;
}
// }
// catch (e) {}
// try {
for (var i=0; i<selectArray.length; i++) {
if (uWindow.GetEntityID(selectArray[i]) != "") {
if (entity_list.value != "")
entity_list.value += ", ";
entity_list.value += uWindow.GetEntityID(selectArray[i]);
}
}
for (var i=0; i<selectArray.length; i++) {
if (msisdn_list.value != "")
msisdn_list.value += ", ";
msisdn_list.value += uWindow.GetMSISDN(selectArray[i]);
}
// }
// catch (e) {}
// try {
// entity_list.value += uWindow.GetEntityID(selectArray);
// msisdn_list.value += uWindow.GetMSISDN(selectArray);
// }
// catch (e) {}
}
}
function fixButtons()
{
addGlobalStyle("span.stext {white-space: nowrap !important; }");
addGlobalStyle("div.stext {white-space: nowrap !important}");
addGlobalStyle(".sbutomid {width: auto !important}");
}
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}