Tab Aliaser 2
Friday, 4. January 2008, 22:54:45
Tabs are narrow, and titles often are long - so you can end up looking at the uninformative beginning of a name and wondering what the page is. Offered here are two complementary 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.
(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
This is a user javascript file. They specify changes for the browser to make to pages during rendering. (Opera runs every script in your userjs folder every time a page is loaded.) The dictionary is just a set of rules that tell the browser to check the URL and title of the webpage being loaded, and to change the title if one of the specified conditions is met.
To set it up, you must have a userjs folder and user javascript switched on, as detailed here. Then make an "alias dictionary.js" file. Here's a sample dictionary that can serve as a template, demonstrating three useful types of commands which will cover most needs:
document.addEventListener('DOMContentLoaded',function() {
if (location.href=='http://jkkmobile.blogspot.com/')document.title='alias1';
if (location.href.indexOf('google.c') !=-1) document.title='alias2';
if (document.title.indexOf('Wikipedia, the f') !=-1)document.title = document.title.slice(0,-23);
}, false);
- 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.
- second line: "href" is the javascript term for URL. This is the type of IF condition that specifies an exact match for a full URL - the rule works for just one page.
- third line: "indexOf" asks where in a tested string T (the URL in this case) a search string S (google.c in this case) 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 'google.c' is in the URL", and the rule aliases any page from Google.
- 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.
- last line: the "false" is a javascript quirk which means nothing much, but must be there.
Copy the sample rules as often as needed, replacing the variables marked in red to adapt them to your own needs. (It's safest to copy and paste the line, and modify only the variables. Javascript is finicky; for example, the O in indexOf has to be a capital.) You can have as many rules as you like.
slice syntax
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 aliasera 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:
Item, "alias tab"=go to page, "javascript:document.title=prompt('Title:',document.title)||document.title;void 1",1,,"contact4"
- bookmarklet (works outside of Opera too): paste into address field of a bookmark: javascript:document.title=prompt('Title:',document.title)||document.title;void 1
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:
<title>Fred</title><frameset><frame src="http://my.opera.com"></frameset>The third trick, contributed by Shoust, was the bookmarklet: a little javascript program which goes in the address field of a bookmark, and is run by clicking the bookmark. Here, it automated assembly of the data URL: prompting for an alias, and pasting it and the URL of the current page into a template.
Setup: make a bookmark named "aliaser", copy this:
javascript:var alias=prompt('Enter alias (page will reload)','');var content='<title>'+alias+'</title><frameset><frame src="'+location.href+'"></frameset>';location.href='data:text/html,'+escape(content);and paste it into the address field. Then click it to alias the current page. A dialog comes up, you enter the alias - and the page reloads under its alias before your very eyes!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"; here's a button for that: unalias








DomCas # 5. January 2008, 11:29
1) Calls the title alternate and I type the title
2) Shows the title as alternate TabName
Has the magica could not be the only step 2 recovering the alternate title of the field title in Favorites since the step of acquiring the title already occurs at the stage of entering Favoritos.Ctrl + D
DomCas
bpm # 5. January 2008, 19:08
When you make a bookmark, the HTML title is automatically inserted in the NAME field of the bookmark. If you change the bookmark name, it does not change the HTML title. But if you use the ALIAS function to "rename" a page, and then bookmark it, the alias will be the automatic name of the bookmark - so you changed both HTML title and bookmark name, by typing the alias once.
I think you suggest a function that reads the name of an existing bookmark and makes a wrapper page with that name as its title. You could do this - but it is not quicker. You still must type the name at some point.
I hope this is clear, across the language gap.
DomCas # 6. January 2008, 12:11
I noticed some side effects:
Suppose that users have an average Bookmarks (Favorites) with 100 entries registered (lines) (200? 500? 1000? lines).
Of Names (titles) suggested (Ctrl + D) a user conservative does not change any , a user progressive change 60% and a user radical change 100%
The conservative nor adopt the proposed script, the progressive perform the procedure 60 times and 100 times radical
What is the procedure?
A) Call the url desired
B) Call Aliased and enter the title (name)
C) Insert the new Tab as favorites
D) Delete the entry cited in a)
In addition, the store will urls the original size to a huge size, because in each of them is stored the script. See example below:
GooTrad I> P http://translate.google.com/translate_t?hl=pt-BR
GooTrad I> P data: text / html; charset = UTF-8,% 3Ctitle% 3EGooTrad% 20I% 3EP% 3C/title% 3E% 3Cframeset% 3E% 3Cframe% 20src% 3D% 22http% 3A / / translate.google. com / translate_t% 22% 3E% 3C/frameset% 3E
What would be the procedure if wanted to change the nickname of one of Favorites?
If your magic now consider that purchase and store aliases associated with URLs are already well served by Ctrl + D is limited to moving the title (name) of the URL simply believe that a single script and not a nickname for each URL with neither having to do 60 procedures on average, each with 4 steps.
bpm # 6. January 2008, 19:05
Real point is that there was no way of permanently renaming pages in Opera until now. With frameset-page technique, it is possible. This is basic change in user power. File bulk and convenience of command are issues of detail: secondary, possible to address if felt important.
Regarding concern about file size, I think it is not a real problem. This is age of 1 GB RAM; each alias, done as data URL, adds 100 bytes (your example: 49B for simple URL, 150B for data URL, with no extra spaces & removing unneeded CHARSET spec). So if someone makes 100 aliases, that is 10 kB: less than one small jpg image.
(Bookmark does not store script: it stores data URL.)
Regarding inconvenience, you have idea people already have made good short names using Ctrl+d. Why? Was not very useful before: only showed up in bookmark list. Short name is much more important for tabs. So story that people have made good aliases already by renaming their bookmarks is not true for most people - and name that is best for bookmark panel is maybe too long for tab.
You would like script which generates data-URL on the fly, by pasting name and URL from bookmark into template. That would be a good function. If you get it done I will thank you. For now, I have given you method to rename pages - which can be developed further if one wishes.
(To change alias, use Maximize Frame to get back to non-alias state, then Aliaser - or edit alias in bookmark URL field.)
DomCas # 6. January 2008, 22:10
Unless expressly forbidden to see a script Favorites, develop steps to acquire and store name would at least redundancy.
I do not understand the resistance to simplify your routine, limiting itself only to show the name previously stored.
As for the argument that store data in quantities between 3 to 4 times larger than the original size would not be problem, I do not agree. That is the culture of waste, which means that people do not worry with a tap barely closed with a light on for the day, print, mail, linked with nobody watching TV etc ...
Minimizar que o bookmark depende de ajustes no nome a ser armazenado é desconhecer que ele mais tarde será consultado para carregar a URL e se ele não estiver em forma inteligivel você não encontrará nada.
As an example below 5 sites for you store respecting the title suggested, and then see it in your bookmark their tabs.
http://www.whitehouse.gov/
http://www.intel.com/
http://www.nycvisit.com/
http://www.ca.gov/
http://www.cartoonnetwork.com/
-----
If I knew Javascript not be taking the job of trying to convince you. We have written the code.
I recall that was done a javascript to the Maxthon that renames all Tabs using the content of the names / titles stored on the bookmark. Not have to do anything unless install the plug-in.
Why here may not be so?
Please understand that I am not fighting, I am just trying the best for us and for the Opera.
Best regards
bpm # 6. January 2008, 22:20
Select all & cut & insert,"data:text/html,%3Ctitle%3E Alias%3C/title%3E%3Cframeset%3E%3Cframe%20src%3D%22" & paste & insert,"%22%3E%3C/frameset%3E"
Put your cursor in URL field of bookmark & execute that function. Data URL which includes old URL is created. Then copy alias you want to use from Name field, select placeholder word "Alias" & paste. Now data URL has name and URL from old bookmark.
Domcas: you don't need to know javascript to do a batch conversion: you can use BASIC or any capable programming language. The ADR file is formatted; it is not hard to write a routine which locates name and URL for each item, and assembles a data URL. Just what is described above, turned into a routine. It does not appeal to me. I don't want to alias all my bookmarks; I am more interested in dynamic aliasing which will capture browsing history, and make the tab bar into a tree view.
Regarding "resistance" to using existing bookmark names: not resistance - lack of interest. Most sites never get bookmarked. I created the function thinking of people using it to alias new sites, so that they can see what is what on the tab bar. This is a more common use than converting old bookmarks - which really can be done in a few minutes if one cares to do it.
If the macro language in Opera were a little better, it would be easy to write a program which created data URLs on the fly from the information in bookmark fields, without having to store the common elements repeatedly. But it is very limited, and is defeated by simple things like the time lag to open the second page of the bookmark dialog. In this context, one must accept compromises.
Regarding a 10 KB filesize increase being evil, immoral and careless: it is not careless waste at all; it is the most efficient way I know to provide a new function. The data URL is much smaller than - for example - a favicon; be thoughtful and realistic, or you will not be taken seriously.
DomCas # 7. January 2008, 10:20
End my participation here. I do not want to rebater arguments with offenses.
Stay in peace, with luck and health.
DomCas
nizamx # 5. August 2008, 20:21
bpm # 5. August 2008, 20:28
nizamx # 6. August 2008, 11:03
aparente001 # 1. August 2009, 16:28
ValleB # 2. November 2009, 01:21
one thing. the bookmarklet by shoust isn't working. the code simply doesn't make its job. now it works:
bpm # 4. November 2009, 04:17
But you should switch to the userjs dictionary - much cleaner method.