Just FYI, There's been a native javascript trim() function since Firefox
3.5.
On 12/18/2012 3:58 AM, Prakash Ranganthan wrote:
The following is my greasemonkey script I have text "ABC-2105" in my
text file in a line and in the website I have "ABC-210" it is actually
matching both text and getting the text value I dont know what went
wrong. Any help is much appreciated. Thanks in advance
function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}
GM_xmlhttpRequest({
method: 'GET',
url: 'http://*******/newscript/Test.txt',
ignoreCache: true,
headers:
{
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept':'text/plain',
},
onload: function(responseDetails)
{
var atcid = new Array();
atcid = responseDetails.responseText.split("\n");
var tempo =document.getElementsByTagName('p')[6].textContent;
var cid = tempo.split(":")
var tc = trimAll(cid[1]);
var tempcid = tc.split(" ")
var datcid = tempcid[0];
var logo = document.createElement("div");
logo.style.color = 'red';
var text = document.createTextNode(" None ");
for (x in atcid)
{
var str = trimAll(atcid[x]);
var ttcid = trimAll(datcid);
var result = str.match(ttcid);
if (result != null)
{text.textContent = ' ' +atcid[++x];
break;}
else{ ++x;
text.textContent = ' ';}
}
--
You received this message because you are subscribed to the Google
Groups "greasemonkey-users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/greasemonkey-users/-/QppNKB6MTfAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.