Tab Aliaser 2
Friday, January 4, 2008 10:54:45 PM
Tabs are narrow, and titles often are long - so you can end up looking at the beginning of a name and wondering what the page is. Here are two solutions: an alias dictionary to permanently give webpages short, clear names or trim off clutter, and a temporary aliaser (from AyushJ) that lets you rename, label or annotate tabs on the fly.
One use is to reduce some tabs to just a favicon, like Firefox's Faviconize and Chrome's Pin Tab (a button for that: Nameless; reload page to restore name), making things very compact, if you edit your skin file to reduce minimum tab width:
(Tab Aliaser 1 - a clunky method which originally motivated this post, and does have a certain warped charm - is included as a historical artifact.)
Obviously, any browser maker could put an Alias option on the right-click menu for tabs. Why don't they? Well, people don't demand what they haven't learned to value, and resources are limited. Opera has often been a pioneer; in this matter, Maxthon has that role. Whether it will catch on is unclear: but it's definitely worthwhile. My tab bar is much more useful now, and I wouldn't be happy if my name-trimmers were taken away.
1. Alias dictionary
if (document.title.indexOf('Wikipedia, the f') !=-1)document.title = document.title.slice(0,-23);
- first line: the event listener causes a pause until the page is done loading, ensuring that your alias doesn't get overwritten. Without it, aliasing works only sometimes.
- third line: (this fixes a flaw in MyOpera blog software: click a tag, and the title of the listing page is posts tagged "" - omitting the actual word.) "indexOf" asks where in a tested string T (the URL in this case) a search string S is located. It returns -1 if S is not in T, and the number of characters before S if it is in T. ! means "not", so !=-1 means S is present. So the IF condition is, "if the string 'bpm/blog/index.dml/tag' is in the URL", and the rule slices the actual tag out of the URL and makes it the new title.
- fourth line: this IF condition specifies presence of a string in page name, not URL. The slice command (syntax described below) trims the title; the rule chops ", the free encyclopedia" off each Wikipedia tab.
- change minimum tab width in skin file by unzip/edit/rezip - details here.
In English the sample rule is, "if the Wikipedia slogan is present in the name, chop off the last 23 characters." The function can trim from either end:
- slice(7) cuts first 7.
- slice(-7) keeps last 7.
- slice (0,-7) cuts last 7.
- slice (a,-b) cuts a from left and b from right.
- slice (a,b) cuts a, keeps b. So (0,7) keeps first 7.
2. AyushJ's temporary aliaser
a terrific function which turns the tab into an editable field: a prominent little note you're free to use any way you like. Click the button, an alert box pops up; put in whatever you like, hit Enter - and it appears on the tab. Reload to erase the alias. Takes a bit of thought to appreciate the opportunities this gives. To the left is an image - a vertical tab bar, turned into a notepad. It (perhaps fancifully) shows one of my data-URL divider pages in use, and descent indicators - • and ¶, one for the parent, two for the children. Tabs can be marked with status indicators (e.g. + if there are links of interest); tab bar can be an organizing tool. Also, in Windows panel, Quickfind can be used to show only tabs with particular group markers on them: instantly eliminating clutter, showing only what you want to see. And (also in Windows panel) alphabetic sort can organize the listing into groups. Not that anyone will do it, of course.
Another benefit: you can give a page a good short name before you drag its tab to a toolbar to make a link button - the alias is what will be used as the link-button name.
Three access options:
- button (drag link to toolbar): Alias
- rightclick menu for tabs: copy this line into your Tab Bar Item Popup Menu:
3. (obsolete) Tab Aliaser 1
This technique (prompted by a request on the Opera forums) used three tricks. The first trick repurposed an old-fashioned form of webpage construction known as frames. Frames are used to display multiple web documents (each of which is actually a distinct HTML page) on a single display page. The crucial fact for this purpose was that there is a frameset page which has no content itself but acts as a host and organizer for other pages. The trick was to use a frameset page for no reason except that one got to name it. It only called one page, and therefore didn't do the thing frames were designed to do: an invisible wrapper with a name one could pick. The whole page is one line: here's the general form:
<title>Alias</title><frameset><frame src="url"></frameset>(To create one manually, and see what the method automates: create a blank page (F2, type "opera:blank", Enter), go to View Document Source (View,o or Ctrl+F3) so you can edit, delete everything (Ctrl+u), paste in the above line and swap in an actual alias and URL. Then, when you hit the "save changes" button, you will see the URL open under the alias you have given it.)
The second trick - which eliminated the need to store wrappers as files - was the use of a data URL: a URL which doesn't point to a webpage, but instead contains the data to form a page image. Opera understands them; as of now anyway, Internet Explorer does not. Here's a very simple one: hello page. Hover to see the code, click to generate a one-word page.
So - the idea was to create bookmarks or links with data URLs which generated frameset pages hosting pages one wanted to see. Here's an example: a link to my.Opera.com, aliased Fred. If you hover it, the URL you'll see in tooltip or status field is a data URL (with "%xy" escape sequences standing in for certain symbols). If you click it, you'll get the my.opera.com page - but with "Fred" on the tab, and the data URL in the address field. And if you use "View document source" to find out what's going on, you'll see the source - not for the displayed page - but for the wrapper:
Setup: make a bookmark named "aliaser", copy this:
To make an alias permanent, bookmark the aliased page, or make a link by dragging from the tab to a toolbar. It will be a data-URL bookmark or link, generating a wrapper each time it's used.
Something to be aware of: a link from an aliased page opened in the same tab will open in the frame and keep the alias. To bail out and restore the page to normalcy (with the author's title), the command is "maximize frame"; it's available via the rightclick menu (Frame submenu) - and here's a button as well, which also works as a frame detector (it's dimmed unless the cursor is in a frame): unalias