Imacros: How to do next thing immediately without waiting load page? - timeout

I have imacros code like this:
VERSION BUILD=8871104 RECORDER=FX
TAB CLOSEALLOTHERS
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 0
SET !TIMEOUT 0
TAB T=1
URL GOTO=https://www.youtube.com/watch?v=Qg-nIAnUZwE
TAB OPEN
TAB T=2
URL GOTO=https://www.youtube.com/watch?v=BXVeHWN9Xuw
TAB OPEN
TAB T=3
URL GOTO=https://www.youtube.com/watch?v=cZPYWcAg86Q
TAB OPEN
TAB T=4
URL GOTO=https://www.youtube.com/watch?v=kABkuIF7zWg
The above code work but it is slow because it had to wait to load page before do next tab. So, there is any way to do next tab IMMEDIATELY without waiting load page ? I use timeout but it doesn't work. Thank you very much !

I suggest writing your code in such manner:
...
SET blankHtml file:///D:/blank.html
TAB T=1
URL GOTO={{blankHtml}}
URL GOTO=javascript:{function<SP>setHref(){window.location.href="https:\/\/www.youtube.com\/watch?v=Qg-nIAnUZwE";}var<SP>tot=window.setTimeout("setHref()",100);}
TAB OPEN
TAB T=2
URL GOTO={{blankHtml}}
URL GOTO=javascript:{function<SP>setHref(){window.location.href="https:\/\/www.youtube.com\/watch?v=BXVeHWN9Xuw";}var<SP>tot=window.setTimeout("setHref()",100);}
...
('file:///D:/blank.html' is a path to a blank html-file. Simply needed to run 'URL GOTO=javascript:{...'.)

Related

How to run an Applescript that will click and open all links on a web page?

I'm trying to write a script that will automatically open a webpage http://www.legislation.gov.uk/new/uksi and then click on all the links in the table "All New Legislation".
So far I've managed to get it to open the page but no luck with clicking.
Here's my script so far:
activate application "Safari"
open location "http://www.legislation.gov.uk/new/uksi"
to clickID()
do JavaScript "document.getElementById(id=per).click();" in document 1
end tell
The following example AppleScript code will open the targetURL in a new Safari window, wait for the page to finish loading, retrieve all URLs on the target page, search them for URLs pointing the various Statutory Instruments published today, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
set jsStatements to "var a = document.links; var x = ''; var i; for (i = 0; i < a.length; i++) { x = x + a[i].href + '|'; };"
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari"
set allURLs to (do JavaScript jsStatements in document 1)
end tell
try
set theseURLs to paragraphs of (do shell script "tr '|' '\\12' <<< " & ¬
allURLs's quoted form & " | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
The do JavaScript1 command create a pipe delimited string of all URLs on the page of the targetURL.
The do shell script command takes the pipe delimited string of all URLs and replaces the pipe characters with newline characters, using tr, so grep can return the URLs that match the grepSearchPattern.
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
1 Using the do JavaScript command requires Allow JavaScript from Apple Events to be checked on the Safari > Develop menu, which is hidden by default and can be shown by checking [√] Show Develop menu in menu bar in: Safari > Preferences… > AdvancedIf you are not allowed to enable that setting, the URLs can be collected for processing in another manner, however it uses the lynx third party utility.
Opening the links without the use of the do JavaScript command:
The following example AppleScript code will use lynx to retrieve the URLs from the targetURL, search them for URLs pointing the various Statutory Instruments published today, and if some have been published will open the targetURL in a new Safari window, wait for the page to finish loading, and then open each one in a new tab of the same window the targetURL was opened.
set targetURL to "http://www.legislation.gov.uk/new/uksi"
set theseURLs to {}
set lynxCommand to "/usr/local/bin/lynx --dump -listonly -nonumbers -hiddenlinks=ignore"
set grepSearchPattern to ".*\\.uk/uksi/.*\\|.*\\.uk/ssi/.*\\|.*\\.uk/wsi/.*\\|.*\\.uk/nisi/.*"
try
set theseURLs to paragraphs of ¬
(do shell script lynxCommand & space & targetURL's quoted form & ¬
" | grep " & grepSearchPattern's quoted form)
end try
if (length of theseURLs) is greater than 0 then
tell application "Safari"
make new document with properties {URL:targetURL}
activate
end tell
tell application "System Events"
repeat until exists ¬
(buttons of UI elements of groups of toolbar 1 of window 1 of ¬
process "Safari" whose name = "Reload this page")
delay 1
end repeat
end tell
tell application "Safari" to tell front window
repeat with thisURL in theseURLs
set current tab to (make new tab with properties {URL:thisURL})
end repeat
set current tab to first tab
end tell
else
display dialog " Nothing published on this date." buttons {"OK"} ¬
default button 1 with title "All New Legislation" with icon note
end if
Hint: Mouse over and horizontal/vertical scroll to see full code.
Notes:
In the lynxCommand variable, change /usr/local/bin/lynx to the appropriate /path/to/lynx. lynx can be installed using Homebrew
The grepSearchPattern variable currently only searches for Statutory Instruments, as I assume that is all that will show under All New Legislation on the page the targetURL opens to, because of /new/uksi in the targetURL, and what I've observed at that URL since you posted the question. If you also want links for other types of legislation, the grepSearchPattern variable can be adjusted to accommodate.
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

Cordova InAppBrowser PDF- iOS

My code is working but not exactly the way I want. I'm using the plugin cordova-plugin-inappbrowser. I have an anchor tag to click and opens up a pdf. The code is as follows:
$("#lnkTools").click(function(e){
//e.preventDefault();
url = 'someExternalLink.pdf';
var options = {location: 'yes', clearcache: 'no', toolbar:'no', closebuttoncaption: 'DONE?'};
$cordovaInAppBrowser.open(url, '_blank', options);
}
The problem I'm facing is that, the PDF doesn't open if I don't exit the app, I have to exit the app first and get back in for the PDF to open up. What am I missing? When I try to use _system same thing, before it opens up the browser, I still need to exit the app first.
EDIT:
When I try to change the $urlRouterProvider.otherwise('/app/main'); in my app.js to $urlRouterProvider.otherwise('/app/login'); it's working, well. Why is this like this? when I place a $state.go('app.main') in my login controller, it loops. Is there any way I can get through this?

Detect empty, new tab openings in Google Chrome

I just published a Google Chrome extension which loads background images into new, empty tabs. The plugin is found here in the Chrome Web Store.
For detecting new and empty tabs, I need to ask for "tab" permissions in the extension's manifest.json. This, however, gives the extension the permission to read the browser's history. Not all users will want this and we don't actually need it. Is there a way to detect empty tabs without this permission requirement? Currently our check looks like this:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
if (changeInfo.status == "loading" && tab.url == 'chrome://newtab/')
{ /* load background into tab */ }
});
If you want to customize the new tab page you should add this to your manifest:
"chrome_url_overrides": {
"newtab": "newtab.html"
}
Then place the script you are currently injecting into new tab pages as a <script> tag in the newtab.html file. That won't cause that permission message.

how to load url from txt file and usng imacro

I have imacro enterprize edition. I want to load URL from a .txt file and visit the pages, and then fill a form. The form is the same for all the URLs. For a single page, I can make the macro but cannot make the macro that load the next URL from a .txt file and do the same work.
I have searched a lot and made a code that can load an URL from .csv file and visit a page. But it is not working. Here it is:
VERSION BUILD=7401004 RECORDER=FX
TAB T=1TAB CLOSEALLOTHERS
SET !DATASOURCE input.csv
SET !DATASOURCE_COLUMNS 7
SET !DATASOURCE_LINE {{!LOOP}}URL GOTO={{!COL1}}
What might I be doing wrong?
You have to define a variable for the loop:
VERSION BUILD=8940826 RECORDER=FX
SET !DATASOURCE c:\input.csv
SET !DATASOURCE_COLUMNS 7
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO={{!COL1}}
...

Data Repeater, make linklabel open link in browser?

I have a datarepeater set up, i have a linklabel showing a link to a webpage. How do i go about making this open in a browser?
I know i should be using
Shell("c:/program files/internet explorer/iexplore.exe URLHERE")
Or similar.
But i dont see how to make it call the value and then create it as a link for that linklabel?
Thanks
I assume you have your linklabel text set as the URL, if so use this in the linklabel click handler
Shell("c:/program files/internet explorer/iexplore.exe" & sender.text)

Resources