So, one day I needed to quit Safari for some reason. The problem was that I had a window with something like 10 tabs open and I needed those pages still. I really find it a pain that I have to bookmark each tab separately, otherwise I would just bookmark all the tabs at once and load them back up when I restarted Safari, but Safari doesn't do this.
I did a little searching and found some scripts on John Gruber's site that saved and restored windows in Safari. This looked good, but it didn't save/restore tabs in those windows. So starting with John's scripts, I added support for tabs to the save script. After learning about GUI Scripting I came up with the following -- read the rest of the hint for the scripts.
I've made a summary with all information about CSS and ADS blocking. The result is an CSS file which, used as default style sheet, can hide all advertising banners in images, texts or animations format even embeded into javascript! This works of course with all browsers ...except Internet Explorer! But who cares?
You can find the stopADVbanners.css file on my website. Just save this file on your hard drive then open the preferences panel of your favorite browser (Mozilla, Netscape, Apple Safari, Opera, etc) and choose this file as "preferred style sheet".
Some very easy CSS tricks I used:
/* disable ad image linking to advertising script */
A:link[HREF*="doubleclick"] IMG,
/* disable ad texts linking to advertising script */
A:link[HREF*="?banner"],
/* disable Flash banner ads */
embed[type*="shockwave"][width="468"][height="60"],
object[codebase*="shockwave"][width="468"][height="60"],
/* disable ad iframes */
IFRAME[SRC*="valueclick"],
/* disable ADV images as specified by www.iab.net */
*[width="468"][height="60"], *[width="468px"][height="60px"]
{ display: none !important; visibility: hidden !important; }
[robg adds: Here's my obligatory webmaster comment ... if you block all ads all the time, those sites that rely on ad revenue may eventually start charging for access (see recent warnings on Macintouch, MacSurfer, etc.). I leave most ads enabled, only blocking pop-ups and highly annoying Flash ads, and occasionally buy stuff via click-throughs just to support my favorite sites ... one could argue the merits of the advertising-supported web model forever, though, and this hint does provide some good solutions to blocking highly annoying ads.]
You can pre-configure Mozilla so that all users get the same preferences when they create a new profile. For example, you might want to define a preference for /tmp, or /Users/Shared as the cache directory, so that users with network home directories will use the local drive for cache. These prefs are stored in a javascript file called user.js which needs to be saved to
/Applications -> Mozilla.app (control-click and select "Show Package Contents") -> Contents -> MacOS -> defaults -> profile -> US -> user.js. In your user.js file, lines which begin // are comments, so you could enter, for example:
//
// user.js: Personal prefs which mozilla shouldn't overwrite.
//
user_pref("browser.startup.homepage", "http://www.my.server.edu/");
user_pref("intl.accept_languages", "en-au, en, en-us, zh, zh-cn, zh-hk, zh-sg, zh-tw, fr, de, de-de, de-at, it, ja, pl, ru, es, sv, fi, sr, hr, da, nl, fr-ca, fr-fr, id, in");
user_pref("intl.charset.default", "UTF-7");
Note that user.js has unix line endings, so use a command line text editor, like vi or pico for editing ... or use BBEdit with the appropriate setting.
I have made some search plugins for the MacOS X Hints and Versiontracker lovers who use Mozilla Firebird as their default browser. The search plugins enable you to search within Mozilla Firebird by using the search box -- each site appears as a new option in the drop-down menu under the magnifying glass in the search box.
You can download the plugins from the macosxhints' download collection -- Search Plugins (4KB). After downloading and expanding the archive, you can install the extensions by control-clicking on Mozilla Firebird. Select Show Package Contents from the pop-up menu, and then navigate to Contents -> MacOS -> searchplugins in the new window. Copy the contents of the downloaded SearchPlugins -> Plugins folder into the searchplugins folder, and launch Mozilla Firebird. You should now have two new search engines in the drop-down menu in the search box.
[robg adds: I tested these, and they work as described, allowing easy searches of both macosxhints and versiontracker.]
Activate the debug menu in Safari, either by using the excellent Safari Enhancer or by shell command defaults write com.apple.Safari IncludeDebugMenu 1
Check the option "Log JavaSript Exceptions" in the Debug menu
Check your Console.app and there is your output!
[robg adds: Mozilla also has access to a Javascript debugger in the Tools -> Web Development menu.]
Today I found out how to get an image file's dimensions from within Safari, and I thought I'd share. You'll need the Debug menu enabled.
Load the image into its own window (or tab). If the image is embedded in within a document, control- (or right-) click on it and choose "Open Image in New Window."
Go to the Debug menu and select "Show View Tree." Option-click on the disclosure triangle next to the only visible line.
The last row of the "Width" and "Height" columns should tell you the image's dimensions.
If all you need are the dimensions of a current image, this will save some time over the "drag to desktop, open in photo application" process.
For the last couple of months, all new windows I opened in Internet Explorer were really small, with a width of about one quarter of the screen, and showed up on the right side of the screen. Trashing Explorer preferences did not fix it since, as I found out today, the default window size for the Explorer is stored in com.apple.internetconfig.plist found in ~/Library -> Preferences. Instead of just trashing this file, which would have required resetting of a lot of preferences, I tried to find the relevant line and just change it.
To do this, first quit Explorer, open the .plist file with the PropertyList Editor (should be the default if you have the Dev Tools installed), open the first three triangles, scroll down to 'InternetExplorerWindowPosition' and open its triangle. The second block of numbers sets the window size; in my case they looked like: 031c045a, 31 sets the height of the window, 45 the width. Change the numbers, save the file, restart Explorer.
Now if someone could find out where the size of windows resized with the green button is set, I would be happy!
... well kind of!
Google has launched a calculator function (Google calculator) which also works very nicely from the Google search field built into Safari.
Fire up Safari and type an expression into the Google search field. Hit enter and Google gives you the result. As well as simple arithmetic (eg 5+2*2), it can also do more complex stuff like sine(30 degrees) or e^(i pi)+1. It knows about physical constants and can also handle conversions for example, 100 miles in kilometers or 160 pounds * 4000 feet in Calories.
[robg adds: Obviously, you can do this from any application that accesses Google; it works really well with the pop-up search engine front-ends such as Searchling and Huevos.]
I just realized that you can save small pieces of text as bookmarks in Phoenix (Mozilla Firebird).
I have a folder in my bookmarks bar, by accident I drag'n'dropped a pieces of text from webpage to this folder (I intended to release the mouse button over the desktop to create a clipping) and interesting enough, a "bookmark" was created with all text in the first paragraph of the text dragged. Of course, this is not a valid bookmark, however it can be very useful to store small snippets of text from webpages (e.g., phone numbers).
[robg adds: This only works for short text snippets, as you can't load the clipping -- it seems to display the first 30 to 40 characters or so.]