Re: Can't get the change download folder in Safari script to work - ui scripting
Re: Can't get the change download folder in Safari script to work - ui scripting
- Subject: Re: Can't get the change download folder in Safari script to work - ui scripting
- From: Tommy Bollman <email@hidden>
- Date: Tue, 15 Mar 2011 12:46:37 +0100
Hello Christopher.
Thank you very much, that is a splendid idea, to find links in one document to the other,
then maybe put the list of matches into a choose from list, which then can be fed to curl.
Second thoughts, when I get to a page full of links, and only wants to download a selected few, then this might be ideal.
My problem was, that I worked on several projects which all has their own download folder.
Then I just download the stuff, without having to move stuff out of my downloads folder.
This takes at least 10 seconds to do from preferences in safari, with the hazards of not hitting the right buttons right away.
So usually stuff hit the downloads folder, then I had to open the downloads folder, then open
the folder the stuff was to be placed in etc etc.n -1 minute.
Now I have the handler that works, I have added a menuitem in the script menu named downloads folder. I have one script for each folder I want to download stuff in. It is easy
accessible. It takes 1 sec. Only thing I have to do, is ALLWAYS to click a folder before I download/click on pages (unless I know for sure I did that 5 mins. ago).
The script which Yvan wrote for me, including invoking it, takes one second.
It works perfectly.
*Totally recommend for people who download stuff in different contexts.*
I't must be said that I have a high throughput in my downloads folder, which necessitates its cleaning on a regular basis.
Den 15. mars 2011 kl. 05.54 skrev Christopher Stone:
> On Mar 14, 2011, at 12:56, Tommy Bollman wrote:
>> Thanks alot. And this script is incredibly useful for people who have to download
>> papers like students and others.
>
> ______________________________________________________________________
>
> Hey Tommy,
>
> I'm not certain what you're doing, however you might want to move outside of Safari to do your downloads.
>
> ------------------------------------------------------------------------------------------------
> # ยป SAFARI_LINKS :: GET LINKS FROM SAFARI USING JAVASCRIPT AND A REGULAR EXPRESSION
> ------------------------------------------------------------------------------------------------
> on SAFARI_LINKS(regexStr, tagName, tagType)
> set js to "function in_array (array, item) {
> for (var i=0; i < array.length; i++) {
> if ( array[i] == item ) {
> return true;}}
> return false;}
> var a_tags = document.getElementsByTagName('" & tagName & "');
> var href_array = new Array();
> var reg = new RegExp(/" & regexStr & "/i);
> for (var i=0; i < a_tags.length; i++) {
> var href = a_tags[i]." & tagType & ";
> if ( reg.test(href)) {
> if ( !in_array(href_array, href)) {
> href_array.push(href);}}}
> href_array;"
> try
> tell application "Safari" to set linkList to do JavaScript js in document 1
> on error
> set linkList to {}
> end try
> return linkList
> end SAFARI_LINKS
> ------------------------------------------------------------------------------------------------
>
> set regexStr to ".*"
> set linkList to safari_links(regexStr, "a", "href")
>
> This will let you search for links in the front Safari Document, and from there you can use 'curl' to download what you want to wherever you want without having to go through any rigamarole.
>
> If you want to know more let me know.
>
> --
> Best Regards,
> Chris
Best regards
Tommy Bollman
--------------------------------------------------------------------------------------------------
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review
and be implemented it wasn't worth doing.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden