I upgraded to Safari 6 and was upset that when I added a new bookmark I got the beach ball of death (is there also a beach ball of life). I impatiently killed Safari after 10 secs or so.
I tried adding bookmarks in any way I could, but always it seemed to hang.
Finally I resolved to give up but left Safari spinning. When I came back the bookmark was added. Not sure what it was doing or thinking about (perhaps whether there is also a beach ball of life), but now I can add bookmarks again without any delay.
Posts Tagged ‘safari’
Safari 6 (almost) hangs when adding new bookmarks
Tuesday, March 26th, 2013Switch search to google scholar bookmarklet
Monday, March 25th, 2013I upgraded to Safari 6 and was happy to see the search bar gone and keyword search directly in the address bar. However I was annoyed to see that when searching you don’t see the full google url but just the query keywords. This nullified my previous hack to switch a google search to a google scholar search.
Instead here’s a little bookmarklet to switch a google search to a google scholar search:
javascript:(function(){window.location.href=window.location.href.replace("search?", "scholar?");})()
Just paste that into you address bar and create a bookmark for it. Then any time you do a normal google search, you can switch it to a google scholar search by hitting the bookmark.
Scroll a bit in safari window, take screenshot repeat
Friday, February 22nd, 2013Here’s an applescript I used to make a series of screen captures of scrolling through a web page in safari:
tell application "Safari"
activate
set sc to 0
repeat
set thescript to "if((window.pageYOffset + window.innerHeight)<document.body.clientHeight)
{
window.scrollBy(0,10); // horizontal and vertical scroll increments
}"
do JavaScript thescript in current tab of first window
set imagePath to (path to desktop as text) & "screenCapture_" & my zero_pad(sc, 6) & ".png"
delay 1.5
do shell script "screencapture -o -mx -T0 " & quoted form of POSIX path of imagePath
delay 0.5
set sc to sc + 1
end repeat
end tell
on zero_pad(value, string_length)
set string_zeroes to ""
set digits_to_pad to string_length - (length of (value as string))
if digits_to_pad > 0 then
repeat digits_to_pad times
set string_zeroes to string_zeroes & "0" as string
end repeat
end if
set padded_value to string_zeroes & value as string
return padded_value
end zero_pad
Fullscreen, blank homepage
Saturday, September 3rd, 2011I usually use a blank or empty page as my homepage. This makes for quick browser start up and minimal waiting when making new tabs/windows.
I find myself often opening a new browser window resizing it to fill the whole screen and then browsing. This goes against how apple wants me to use my mac. The little green plus sign button on the top left corner of the screen is supposed to be smart enough to always maximize the current window only as much as it needs to/should. But what is the correct maximization of a blank page? Apparently its a full height window with some arbitrary width. Why not make it a full height and full width window. To do this for my browsers (Safari, Firefox, Chrom(e|ium)) I made a little html file that displays a blank, fullscreen-able page. Save the following in a file on your computer called fullscreen-homepage.html:
<html>
<head>
<title>Fullscreen Homepage</title>
</head>
<body style="min-width:10000px;overflow:hidden">
</body>
</html>
Open the file with your browser and copy the address at the top (starting with file:// to your browser’s preferences as your homepage for new tabs and windows. Here’s what to change in the Safari preferences:

Getting Safari to play a short audio clip with HTML5′s audio tag
Friday, August 19th, 2011I had a really annoying time trying to get Safari to load and play a small audio clip (mp3) I’d posted. The clip is only 2 seconds. Here’s the HTML I was using
<audio src="audio.mp3" autoplay preload="auto" controls loop>
But this resulting in nothing. Upon closer inspection I found out the the “onstalled” even was being fired so I added an “onstalled” even handler to try to load the clip again:
<audio onstalled="this.load();" src="audio.mp3" autoplay preload="auto" controls loop>
But this was to no avail, the “onstalled” event just fired each time recursively.
In the end I gave up on Safari’s ability to play/load small mp3 files. I’m not sure what the problem is since quicktime played the file fine. Also if my html and audio.mp3 files lived locally, Safari played it correctly.
I instead made use of HTML5 ability to specify fallback sources. For this I converted my mp3 file to a m4a:
First convert to wav with mplayer:
mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="audio.wav" "audio.mp3"
Then convert to m4a with faac:
faac -o audio.m4a audio.wav
Finally use the .m4a file as a fallback source in the audio tag:
<audio autoplay preload="auto" controls loop>
<source src="audio.mp3" >
<source src="audio.m4a" >
<audio>
Ignore the onion paywall
Saturday, August 13th, 2011Was watching the onion video channel today and to my surprise they have a paywall like nytimes. To be honest at first I thought it was a joke. But in the end it’s just as easy to get around as the nytimes one.
Just a little client side javascript gets ride of the paywall screen:
document.getElementById('gregbox-overlay').style.display = "none";
document.getElementById('gregbox-wrap').style.display = "none";
And here’s an applescript which calls that javascript on the frontmost safari window.
tell application "Safari"
try
set doc to front document
do JavaScript "document.getElementById('gregbox-overlay').style.display = 'none';" in doc
do JavaScript "document.getElementById('gregbox-wrap').style.display = 'none';" in doc
on error errText number errNum
end try
end tell
Hack infinite scroll javascript with infinite auto-scroll to bottom of page
Thursday, January 7th, 2010This is a hack to have your browser load all search results when a page is using jQuery’s infinite scroll feature, like this site: http://instantwatcher.com/titles/all?infinite=1.
Here’s the client side javascript to keep auto-scrolling this page to the bottom, thus triggering infinite scroll to load more results. It runs until there are no more results to load:
function scrollToBottom(){
bottom = document.body.scrollHeight;
current = window.innerHeight+ document.body.scrollTop;
if((bottom-current) >0){
window.scrollTo(0, bottom);
setTimeout ( 'scrollToBottom()', 1000 );
}
};
scrollToBottom();
I run this on Safari using this short applescript:
tell application "Safari"
set doc to front document
set this_url to URL of doc
do JavaScript "
function scrollToBottom(){
bottom = document.body.scrollHeight;
current = window.innerHeight+ document.body.scrollTop;
if((bottom-current) >0){
window.scrollTo(0, bottom);
setTimeout ( 'scrollToBottom()', 1000 );
}
};
scrollToBottom();
" in doc
end tell
Javascript: scroll to bottom of page/window
Thursday, January 7th, 2010Seems to work great in Safari and Firefox. Will check IE later…
window.scrollTo(0,document.body.scrollHeight);
Open lines in clipboard as URLs in Safari
Saturday, November 14th, 2009I used to use a script that took the lines of a text edit document and opened each as a url in Safari. This was useful when I used text-edit. Now I’m using Terminal and other apps to gather urls so its easier and more general to just copy the urls to the clipboard (CMD + C) and run this script. The applescript below opens each line of the copied text as a new safari window setting the line as the url.
set clipboard_contents to the clipboard as text
set urlList to paragraphs of clipboard_contents
set numURLs to (count urlList)
tell application "Safari"
activate
repeat with this_url in urlList
if length of this_url is greater than 0 then
set this_doc to make new document at end of documents
set URL of this_doc to this_url
end if
end repeat
end tell
Note: There are lots of hacks to open a list of urls as tabs, find one and use it if your desire tabs. I didn’t post this for tabs because as far as I know opening a bunch of tabs always requires and awkward hack like using system events and keystrokes etc.
