Pizza Pro 11 Posted November 19, 2016 Report Share Posted November 19, 2016 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! Quote Link to post Share on other sites
Macster (UBotter Labs) 112 Posted November 19, 2016 Report Share Posted November 19, 2016 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. 2 Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 Oh! You can use "focus" to select innertext? Didn't know that. Thanks! I'll give it a try. Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 Hmm... I tried it and "focus" doesn't seem to work for innertext in a text document. The screen doesn't even move... Anyone know any javascript I can use to do it? Quote Link to post Share on other sites
pash 504 Posted November 19, 2016 Report Share Posted November 19, 2016 try run javascript("window.scrollTo(0,document.body.scrollHeight);") Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 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. Quote Link to post Share on other sites
deliter 203 Posted November 19, 2016 Report Share Posted November 19, 2016 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 1 Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 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. Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 I tried the solution on this page, but I couldn't get it to work either. Maybe I did it wrong though: - http://stackoverflow.com/questions/2820086/javascript-find-and-scroll-to-text Quote Link to post Share on other sites
stanf 43 Posted November 19, 2016 Report Share Posted November 19, 2016 i'm not the best uboter here,but i gave it a shot, could not do it with ubots browser.but did not find it a problem with exbrowser Quote Link to post Share on other sites
stanf 43 Posted November 19, 2016 Report Share Posted November 19, 2016 i stand corrected navigate("http://stackoverflow.com/questions/2820086/javascript-find-and-scroll-to-text","Wait")wait(12)run javascript("$(window).scrollTop($(\"*:contains(\'Are you a Lib Dem or Tory\'):last\").offset().top);")i love a puzzle 2 Quote Link to post Share on other sites
luis carlos 94 Posted November 19, 2016 Report Share Posted November 19, 2016 OMFG, Thanks!i stand correctedi love a puzzle Quote Link to post Share on other sites
Pizza Pro 11 Posted November 19, 2016 Author Report Share Posted November 19, 2016 i stand correctedi love a puzzle Oh. So it works! 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? Quote Link to post Share on other sites
stanf 43 Posted November 20, 2016 Report Share Posted November 20, 2016 i dont think you can .the editer is in an iframe and ubot does bot deal with iframes well Quote Link to post Share on other sites
Pizza Pro 11 Posted November 20, 2016 Author Report Share Posted November 20, 2016 i dont think you can .the editer is in an iframe and ubot does bot deal with iframes well I see. Oh well. Quote Link to post Share on other sites
deliter 203 Posted November 20, 2016 Report Share Posted November 20, 2016 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") 1 Quote Link to post Share on other sites
Pizza Pro 11 Posted November 21, 2016 Author Report Share Posted November 21, 2016 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... 1 Quote Link to post Share on other sites
deliter 203 Posted November 21, 2016 Report Share Posted November 21, 2016 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 1 Quote Link to post Share on other sites
Pizza Pro 11 Posted November 21, 2016 Author Report Share Posted November 21, 2016 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! Thanks though! I'll play around with it when I get the time and see if I can figure out a workaround. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.