Jump to content
UBot Underground

How To... Make Ubot Scroll Down To A Specific Phrase In A Document?


Recommended Posts

Hi,

 

I was just wondering if there's any way to make UBot scroll down to a specific phrase in a document?

 

For example, let's say I have a long document, and want UBot to scroll down to the first place where it says "Headline 2".

 

Any easy way to do that?

 

Thanks in advance! :)

Link to post
Share on other sites

 

try

run javascript("window.scrollTo(0,document.body.scrollHeight);")

 

Hi pash,

 

Thanks for your reply. :)

 

It seems to be that this code scroll UBot all the way down to the bottom of the screen.

 

What I'm looking for is to search for a specific block of text, and then scroll down to it automatically.

Link to post
Share on other sites

You can use "focus" and select the element or the innertext.

In some cases where the are multiple similar elements you may need to use the "element offset" parameter.

I sat around for an hour thinking of complicated ways of trying to answer this!couldn't think of a good solution,havnt tried this but sounds like it will work forgot focus even exists

  • Like 1
Link to post
Share on other sites

I sat around for an hour thinking of complicated ways of trying to answer this!couldn't think of a good solution,havnt tried this but sounds like it will work forgot focus even exists

 

Not sure if I did it wrong, but I gave it a try, and it doesn't seem to work for me. :(

 

The screen doesn't even scroll. I guess "focus" only works for individual elements maybe.

Link to post
Share on other sites

i stand corrected

i love a puzzle

 

Oh. So it works! :o

 

I think I'm doing it wrong... Let's say the text I want to scroll to is inside a TinyMCE (Wordpress) editor. What would I have to change in that code to get it to work?

Link to post
Share on other sites

this works for Ubot Chrome 49 only(chrome 49 in settings option),no jquery needed

define ScrollToText(#text) {
    run javascript("function walkTheDOM(node, func) \{
    func(node);
    node = node.firstChild;
    while (node) \{
        walkTheDOM(node, func);
        node = node.nextSibling;
    \}
\}

// Example usage: Process all Text nodes on the page
walkTheDOM(document.body, function (node) \{
    if (node.nodeType === 3) \{ // Is it a Text node?
        var text = node.data.trim();
        if (text.includes(\"{#text}\") === true) \{ // Does it have non white-space text content?
            // process text
         node.parentElement.scrollIntoView()
        \}
    \}
\});")
}
navigate("http://network.ubotstudio.com/forum/index.php/topic/20111-how-to-make-ubot-scroll-down-to-a-specific-phrase-in-a-document/","Wait")
wait for browser event("DOM Ready","")
ScrollToText("this works for Ubot Chrome 49 only")

  • Like 1
Link to post
Share on other sites

 

this works for Ubot Chrome 49 only(chrome 49 in settings option),no jquery needed

define ScrollToText(#text) {
    run javascript("function walkTheDOM(node, func) \{
    func(node);
    node = node.firstChild;
    while (node) \{
        walkTheDOM(node, func);
        node = node.nextSibling;
    \}
\}

// Example usage: Process all Text nodes on the page
walkTheDOM(document.body, function (node) \{
    if (node.nodeType === 3) \{ // Is it a Text node?
        var text = node.data.trim();
        if (text.includes(\"{#text}\") === true) \{ // Does it have non white-space text content?
            // process text
         node.parentElement.scrollIntoView()
        \}
    \}
\});")
}
navigate("http://network.ubotstudio.com/forum/index.php/topic/20111-how-to-make-ubot-scroll-down-to-a-specific-phrase-in-a-document/","Wait")
wait for browser event("DOM Ready","")
ScrollToText("this works for Ubot Chrome 49 only")

 

Thanks Deliter. :)

 

That some pretty advanced looking code! Cool!

 

So it doesn't work in Chrome 21?

 

Chrome 49 isn't working properly for me on some sites for some weird reason, so I'm still using Chrome 21, unfortunately... :(

  • Like 1
Link to post
Share on other sites

Thanks Deliter. :)

 

That some pretty advanced looking code! Cool!

 

So it doesn't work in Chrome 21?

 

Chrome 49 isn't working properly for me on some sites for some weird reason, so I'm still using Chrome 21, unfortunately... :(

 

that code was written by Brendan Eich the creator of Javascript ha so yeah he knows his stuff,I just added the scroll into view bit and the include

 

Yeah 49 only unfortunately soz

  • Like 1
Link to post
Share on other sites

that code was written by Brendan Eich the creator of Javascript ha so yeah he knows his stuff,I just added the scroll into view bit and the include

 

Yeah 49 only unfortunately soz

 

Wow! :o

 

Thanks though! :) I'll play around with it when I get the time and see if I can figure out a workaround.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...