This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
 All Forums
 Lua Scripts
 General Action Scripts
 search in the current Website

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
defpt Posted - 02/17/2013 : 05:27:14
I want to do a gestures for search in the current Website, so it is necessary to obtain the domain name. Is there a function to achieve this purpose?
Thank you very much Rob. The following is the improved Script for search in the current Website:Search for the selected text, or display an inputbox for input string

--Search in this website
function acINSearch(x)
acSetClipboardText("") --clear Clipboard
acSendKeys("%d") --focus on the urlbar
acSendKeys("^c")
acDelay(25)
url = acGetClipboardText()
domain=string.gsub(url,"https?://(.-)%/.*","%1") --Get Domainname
acDelay(25)
newurl="https://www.google.com/search?hl=zh-CN&client=opera&q=site:"..domain.."%20"..x --Search engine, her is for Chinese
acSetClipboardText(newurl)
acSendKeys("^v")
acSendKeys("{DELAY=25}%{ENTER}")
end
acSetClipboardText("")
acSendKeys("^c")
acDelay(50)
text=acGetClipboardText()
if text ~= "" then acINSearch(text)
else inputString= acInputBox("Google Search", "Please enter the string you want to search", "")
if inputString ~= "" then acINSearch(inputString) end
end
4   L A T E S T    R E P L I E S    (Newest First)
defpt Posted - 02/17/2013 : 14:13:55
Thank you very much anyway. :-)กก
I think this and the above are the same principle. I would have thought that, S+ can directly access location.hostname :-P
After learning your string.gsub usage, my function to improve:

acSetClipboardText("")
acSendKeys("%d")
acSendKeys("^c")
acDelay(25)
local url = acGetClipboardText()
acDelay(25)
local domain=string.gsub(url,"https?://(.-)%/.*","%1")
Rob Posted - 02/17/2013 : 09:55:14
Unfortunately you cannot access location.hostname since that's within the javascript engine of the browser, not something exposed to other applications.

This script worked for me to navigate to the root of the current website:
acSendKeys("^l") --goto address bar
acDelay(25)
acSendKeys("^c") --copy URL
acDelay(25)
url=acGetClipboardText() --get the URL from the clipboard
new_url=string.gsub(url,"([http://|https://]+[A-Za-z0-9.]*/+).*","%1") --strip out only root address
acSetClipboardText(new_url) --save the new URL to the clipboard
acDelay(25)
acSendKeys("^v") --paste the URL in the address bar
acDelay(25)
acSendKeys("{ENTER}") --send Enter key
defpt Posted - 02/17/2013 : 09:53:46
I can only complete it by string functions. such as:

function acGetDomain()
acSetClipboardText("")
acSendKeys("%d")
acSendKeys("^c")
acDelay(50)
local s = acGetClipboardText()
local i,j=string.find(s,"//.-%/")
i=i+2
j=j-1
return string.sub(s, i, j)
end
defpt Posted - 02/17/2013 : 05:30:00
or

How can I use "location.hostname" directly?

StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000