/    Sign up×
Community /Pin to ProfileBookmark

Help with conditionals

Hi there, I’m somewhat new to programming and I was wondering if anyone could give me some help with a script I want to create that has some conditionals in it.

I’ll give you a rough idea of how I want to make it to work, in code format, but not in code.

LOOP // to constantly parse the website
IF textOne == “Welcome” {
Click Link x
}
ELSEIF textOne == “About” {
Click Link y
}
ELSEIF textOne == “What” {
Click Link z
}

Basically, I want the script to look at the page and look for some text, textOne (var isnt important). If the text “Welcome” (for example) is found it clicks a certain link, if its something else that is defined, it will click a different link. The link it clicks will be based on the text between the < a > and < / a > because the URLs are dynamic. ie: [url]http://www.what.com/what?p=ashdsahdhads[/url].

does this sound at all possible?

thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CriticalMassCowAug 17.2007 — This is the basic idea of what you want to do.

This script will function properly.

If you need I can be more detailed..

Let Me know.


<html>

<head>

</head>

<body>

Welcome Click Here: <href="http://craigslist.thingweb.com">link text to find</a>

<script language="JavaScript">

var WebPageText = document.body.innerHTML;

var anchorText;

// This is the basic idea of what you want to do

var pattern = /Welcome/i;

var LinkText = "link text to find";

if (pattern.exec(WebPageText) != null){

anchorText = document.getElementsByTagName("a");

for (i = 0; i < anchorText.length; i++) {

if (anchorText[i].innerHTML == LinkText) {

alert('Found it');

anchorText[i].click();

}

}

}



</script>

</body>
×

Success!

Help @tr3online spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...