Plugin = the following is not strictly necessary, but we onlyĬls.item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( # We will retain a pointer to the plugin to prevent it I still had to try a few different paths to get to the tab information I wanted, but it was pretty easy, armed as I was with Python and the output of class-dump. This is a fabulous tool which will read any Cocoa library, bundle, or application and produce a pseudo-header file showing all the objects and methods defined. Once again, I used the handy class-dumputility. The tab behaviour of Safari isn't part of WebKit, so it isn't documented anywhere. The next step was to actually do something once I had my code loading into Safari. They were using the class method initialize() rather than load and when I switched to that things started working, where by "things" I mean, "I could print to the console to see that my class had loaded." The Solution What I did instead was to run the command-line utility class-dump on another SIMBL plugin to see what they were doing. I don't know if it is artifact of using PyObjC or what, but my load() method was never getting called. Mike recommends you put your initialization code into a class method load() which gets called after your class is loaded. Getting started wasn't too bad, but I found one issue in the above essay that stumped me for awhile. What I decided was that, rather than recreate the functionality in SIMBL using Python, I would just create a SIMBL plugin in Python. I also read Mike's essay Armchair Guide To Cocoa Reverse Engineering. SIMBL is open-source, so at first I was looking at the code to see what I need to do to create an InputManager (remember, this is a hack, so Apple doesn't document it very well). Once I figured out that the only way I was going to get Tab Dumping behaviour into Safari (because Safari tabs don't play well with Javascript, that turned out to be a dead-end), I decided to try writing an InputManager in Python. SIMBL takes care of the nasty business of being a well-behaved system hack, and your code can assume it is in the right app, because it doesn't get loaded otherwise. InputManagers get loaded by every application (Cocoa apps, at least), so you have to be careful you're in the app you want to modify, and take steps not to break things. You see, PithHelmet itself is not an InputManager, it is a plugin for SIMBL (also by Solomon), which is an InputManager that loads plugins based on the application(s) they claim to support. Another tool for blocking ads and such (which Saft also does) is PithHelmet, but the interesting thing to me about PithHelmet isn't that it is a popular ad blocker, but that the Mike Solomon (who wrote PithHelmet) decided to not just make an InputManager, but to make the only InputManager you'll ever need. On the other hand, I couldn't keep using Safari if it wasn't for Saft, and Saft is an InputManager. Firefox has tools to help you do this, but I haven't seen anything for Safari, possibly because you can't really do it with a Safari plugin, but need to use an InputManager, which is fairly deep magic, and basically a hack, an abuse of the system. So I send myself a tab dump on a more-or-less daily basis. I do however, find Safari teetering on the brink of being unfunctionally slow because I have so many tabs open, and often they're only open because I want to remember to do something with them later, or come back to them, or some other reminder-type function. I don't currently put tag dumps on the blog because a) I'd feel guilty doing that without adding at least a short comment for each link, which would take too much time, and b) because this isn't really a link blog, more a place for me to bash out example code and tutorials. What it doesn't do is give you a list of all the tabs you have open in text format, suitable for blog or email. Among its many features, Saft will let you consolidate your windows into tabs of one window, and it can save the tabs you have open when you close (or crash) Safari, and re-open them automatically when you start Safari again. I keep Safari running all the time and with the help of Hao Li's wonderful extension Saft I keep everything in tabs in one window. I first saw the term "tab dump" on Dori Smith's blog, but I immediately recognized the concept. Living Code A program is a process, not a thing Tab Dumping in Safari The Problem
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |