Jump to content


Photo

Noobs guide to Javascript strings


  • Please log in to reply
17 replies to this topic

#1 Biks

Biks

    Advanced Member

  • UBot Users
  • PipPipPip
  • 170 posts
  • OS:Windows 7
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Pro

Posted 22 August 2010 - 09:54 AM

I took a whole day to figure out how to trim, delete or replace stuff using a Javascript expression within Ubot, so I figured I might as well share it. I have had not one drop of javascript programming experience, so you hot shot programmers can shrug and scoff all you want. :-) I'll try to explain this from a complete noobs perspective.

My objective: I wanted to trim down any long URL to the basic domain.
Take something like this:
http://www.ubotstudio.com/forum/index.php
Turn it into this: ubotstudio.com


You should be able to use what I show with ANY type of text string. I created a running demo of the javascript strings to show you HOW they would be used within Ubot.

Download: Attached File  Shorten URL.ubot   18.31K   144 downloads


Posted Image

You'll enter a long URL into the UI box above, hit the play button and you'll see the results in the UI stat monitor below. The demo just shows the end result of the variable. You would use this updated variable within your own bots.

Here's everything for pattern matching characters: javascriptkit.com/javatutors/re2.shtml


--- Strip Front Tab -----


Posted Image

The flow is:
'LOOK AT ALL THIS JUNK' .replace /WHATEVER I FIND HERE/ , 'WITH THIS' ;

As a non programer, I was having a hard time figuring out where things started and ended. (/( = is this something? How about this = /, ?

The sections are:

'{1}' = your variable will be inserted here. Just {1} won't work - you need '{1}'
.replace( ); = This is the outside portion of the .replace expression.
/ / = this is an inside group
, = find the stuff to the left of the comma and replace it with what's on the right
( )|( ) = Alterations of groups - (THIS) O|R (THAT) In this instance we're looking either http:// or http://www
'' = empty or nothing. Sometime you WILL have something like '{1}' (a variable)

Notice that there are no slashes here: (http:..www.)|(http:..)
This won't work: (http://www.)|(http://)
Reason: using a / would mean the end of a section. You've got to use a . (dot)
. = match ANY single character


--- Strip End Tab -----


Posted Image

The flow is:
'LOOK AT ALL THIS JUNK' .replace /STARTING FROM THE END AND GOING BACKWARDS, SELECT EVERYTHING AND INCLUDING .COM/ , 'WITH JUST .COM' ;

In reverse order:
$ = start at the end (^ = start at the beginning)
. = ANY single character
+ = match one or more characters

.+. = any character, to any AMOUNT of characters, to any character again. This is the closest you'll come to the standard wildcard (*).

----- Strip both -----

Notice that it strips #URL first and updates #strip, then it strips #strip and updates #URL. By ping pong between variables you can keep updating your original data.

--- Other examples ----

Let's say you wanted just the authors name to a post. The narrowest scape you can do this:

Harry Kabonzi | August 20, 2010

You would run this: '{1}'.replace(/ \x7c.+.$/, '');

The tricky part is the "|" symbol. This won't work: '{1}'.replace(/ |.+.$/, ''); You need to use the hex # for the "|" symbol, which is \x7c. In this case, I'm also adding a blank space before it so I end up with only "Harry Kabonzi". To find more hex #'s, go here.

Again, check out this website for more pattern matching characters: javascriptkit.com/javatutors/re2.shtml

#2 LillyT

LillyT

    Advanced Member

  • Administrators
  • 1264 posts
  • LocationUSA
  • OS:Windows Vista
  • Total Memory:2Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 22 August 2010 - 01:01 PM

Hey Biks,

great job :-)

Perhaps I should move this thread to "Tutorials, Tips and Tricks". Would that be alright with you?

#3 Biks

Biks

    Advanced Member

  • UBot Users
  • PipPipPip
  • 170 posts
  • OS:Windows 7
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Pro

Posted 22 August 2010 - 05:18 PM

Certainly. I was gonna do that, then I noticed a bunch of things like that were moved to here! (Scripting)

#4 LillyT

LillyT

    Advanced Member

  • Administrators
  • 1264 posts
  • LocationUSA
  • OS:Windows Vista
  • Total Memory:2Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 22 August 2010 - 06:42 PM

Certainly. I was gonna do that, then I noticed a bunch of things like that were moved to here! (Scripting)



I'll pin it then for future reference.

#5 Abs*

Abs*

    Advanced Member

  • UBot Users
  • PipPipPip
  • 684 posts
  • LocationUK
  • OS:Windows 7
  • Total Memory:6Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 27 October 2010 - 09:15 AM

hi guys

this is a great thread and very usefull

im a little stuck and was wondering if someone could shed some light as to what im doing wrong

Im trying to load a list of urls from a file then trim them to the route and save the list to another file -

I have over 100 urls in the file however when i strip and save it only saves 1 url

any help is appreciated -

image attached below

thanks

abs

Attached Files


get thousands of backlinks at the touch of a button - Auto Backlink Bomb created in Ubot

Blog commenter software for thousands of auto approved backlinks - made in Ubot

#6 JohnB

JohnB

    Advanced Member

  • UBot Users
  • PipPipPip
  • 3350 posts
  • LocationNJ
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 27 October 2010 - 09:27 AM

Did you place that in a loop to loop through the list? Your image shows an if/then statement, so I am unsure what lies above.

John

#7 Abs*

Abs*

    Advanced Member

  • UBot Users
  • PipPipPip
  • 684 posts
  • LocationUK
  • OS:Windows 7
  • Total Memory:6Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 27 October 2010 - 09:41 AM

hi no loop - the if statement is a evaluate if xx checkbox =true
get thousands of backlinks at the touch of a button - Auto Backlink Bomb created in Ubot

Blog commenter software for thousands of auto approved backlinks - made in Ubot

#8 Biks

Biks

    Advanced Member

  • UBot Users
  • PipPipPip
  • 170 posts
  • OS:Windows 7
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Pro

Posted 27 October 2010 - 05:56 PM

I'm pretty sure you've got to loop it.

Load the first one from your list.
Strip it.
Save it to another list.
Loop. (list total amount)
Save to file.

You've got to apply it one line at a time. You don't feed it a huge list and it change/replaces everything like in a text doc.

#9 Abs*

Abs*

    Advanced Member

  • UBot Users
  • PipPipPip
  • 684 posts
  • LocationUK
  • OS:Windows 7
  • Total Memory:6Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 29 October 2010 - 07:55 AM

ahh bikes - it makes sense -

So just loop list total > get next list item then strip - add to new list - save to file

sounds like a plan

thanks
get thousands of backlinks at the touch of a button - Auto Backlink Bomb created in Ubot

Blog commenter software for thousands of auto approved backlinks - made in Ubot

#10 Super Dave

Super Dave

    Advanced Member

  • Members
  • PipPipPip
  • 133 posts

Posted 11 February 2011 - 11:55 AM

I'd like to recommend that anyone using anything dealing with javascript add this bug fix to their codes.

If the page you're navigating to doesn't contain javascript ubot doesn't have any libraries to go off of either. This fixes that. Skip through the comments and feel free to copy the sub at the end.

Attached Files



#11 bheeelaat

bheeelaat

    Newbie

  • Members
  • Pip
  • 2 posts
  • OS:Windows XP
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard

Posted 19 June 2011 - 09:33 AM

Nice Guide sir! Its verey usefeul especially for newbie like me :P
Posted Image
Hi Guys! I'm New here

#12 ubotapp

ubotapp

    Newbie

  • Members
  • Pip
  • 2 posts
  • OS:Windows Vista
  • Total Memory:3Gb
  • Framework:v4.0
  • License:Standard

Posted 08 December 2011 - 12:40 AM

Does this work in 4.0? I tried to copy the steps in the image, but I don't know how to enter this part into the eval statement so it shows up as a red node:

'{1}'.replace(/.com.+$/,'.com');

where I can put a parameter inside the node.

#13 southsider

southsider

    Member

  • UBot Users
  • PipPip
  • 20 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 14 March 2012 - 11:13 AM

Does this work in 4.0? I tried to copy the steps in the image, but I don't know how to enter this part into the eval statement so it shows up as a red node:

'{1}'.replace(/.com.+$/,'.com');

where I can put a parameter inside the node.



For {1}, drag a drop a variable in between the ' '

#14 soulpower

soulpower

    Advanced Member

  • UBot Users
  • PipPipPip
  • 89 posts
  • LocationBrooklyn, NY
  • OS:Windows 7
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard

Posted 05 June 2012 - 07:05 PM

great info here...i really needed this. Thanx guys

#15 Security

Security

    Advanced Member

  • UBot Users
  • PipPipPip
  • 87 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v4.0
  • License:Pro

Posted 10 June 2012 - 05:28 PM

Can you do the same things using Regex ? or is this way better or something ?

-Thank Capitalism-


#16 inview

inview

    Newbie

  • Members
  • Pip
  • 6 posts
  • OS:Windows 7
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard

Posted 27 September 2012 - 07:42 AM

Great thread.
I wish I could download stuff :(
Just wondering - why would there be a restriction till I have 50?, seems strange?

#17 Aymen

Aymen

    Advanced Member

  • UBot Users
  • PipPipPip
  • 523 posts
  • OS:Windows 7
  • Total Memory:4Gb
  • Framework:v3.5 & v4.0
  • License:Dev

Posted 28 September 2012 - 06:05 AM

Great thread.
I wish I could download stuff :(
Just wondering - why would there be a restriction till I have 50?, seems strange?

if you got a ubot license , contact the support team to make them lift the limitation

#18 inview

inview

    Newbie

  • Members
  • Pip
  • 6 posts
  • OS:Windows 7
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard

Posted 29 September 2012 - 04:32 AM

if you got a ubot license , contact the support team to make them lift the limitation


Thank you for sorting that Aymen, very much appreciated :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users