Bookmarklet to lookup selected word in wiki's abbreviation table

Discussions about the forum and contents
Post Reply
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

Taylor Larimore wrote: Sun Aug 23, 2020 8:05 pm I have noticed an increasing use of posts with many words that I cannot understand. This makes me worry about new investors who come to this forum for the first time to be confronted with words and abbreviations like these:
Your thread got locked, so I can't post this solution there, but this seems like a common complaint.

You can save this script on your bookmark bar and then when you see an abbreviation or acronym you don't recognize, you can double click the word (highlight it) and then click the bookmarklet. A popup window will open on the wiki abbreviation table and if the abbreviation exists, it will jump to that line.

See this post for the final iteration of the script which works in all browsers viewtopic.php?p=5474854#p5474854

Code: Select all

javascript:void(window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#:~:text='+(''+window.getSelection()).trim()+'%20-%20','','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'));
(To create the bookmarklet, the easiest way is to create a regular bookmark and then edit it to change the title and the URL - just paste the code above in the URL box.

Also, this bookmarklet might only work in Chrome browsers. I'm not sure if other browsers support the google "Text Fragment" feature. We could fix this by using "id" tags in our wiki table so that a URL # could jump to the right line, but this is the only alternative I could think of right now.)
Last edited by the way on Sat Sep 05, 2020 8:50 pm, edited 1 time in total.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Great idea! I've linked to this thread from Re: A Plea for Ordinary English.

I'm having a problem getting it to work in Firefox or Chrome. The wiki page opens in a new window, but it doesn't jump to the text. I'll keep working on it.

Is the text case-sensitive? Does it need to be surrounded with a space character?
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
rossington
Posts: 1823
Joined: Fri Jun 07, 2019 2:00 am
Location: Florida

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by rossington »

LadyGeek wrote: Sun Aug 30, 2020 8:19 am Great idea! I've linked to this thread from Re: A Plea for Ordinary English.

I'm having a problem getting it to work in Firefox or Chrome. The wiki page opens in a new window, but it doesn't jump to the text. I'll keep working on it.

Is the text case-sensitive? Does it need to be surrounded with a space character?
It worked for me. Test it on an acronym in a post that you know is in the wiki like DW or SEC.
"Success is going from failure to failure without loss of enthusiasm." Winston Churchill.
User avatar
WoodSpinner
Posts: 3504
Joined: Mon Feb 27, 2017 12:15 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by WoodSpinner »

Doesn’t seem to work in Safari on my iPad iOS 13.6.1

It’s a nice idea though

WoodSpinner
WoodSpinner
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

the way wrote: Tue Aug 25, 2020 11:56 am Also, this bookmarklet might only work in Chrome browsers. I'm not sure if other browsers support the google "Text Fragment" feature. We could fix this by using "id" tags in our wiki table so that a URL # could jump to the right line, but this is the only alternative I could think of right now.)
As a wiki editor with a very strong software background, challenge accepted. :)

I have added anchors to the page. See: Abbreviations and Acronyms

OK, you can't see any changes unless you view the source ("View source" tab). Here's how it looks in wiki text.
*{{anchor|AA}}[[AA]] - [[Asset allocation]]; one of the most important decisions that investors make
The anchor href attribute is the abbreviation. So, selecting "AA" in the forum post will go to Asset Allocation.

I took a stab at the javascript and created a bookmark titled "Acronyms".

Code: Select all

javascript:void(window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+(''+window.getSelection()).trim(),'','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'));
It works in Chrome, but not Firefox.

In Firefox, I get a new wiki window, but it doesn't jump to the anchor. The Mozilla documention for Window.getSelection() - Web APIs | MDN hints of a compatibility problem, but I don't have any real experience with javascript to figure out how to fix it.

Can someone who knows javascript please assist?

Now that we have the format figured out, it's easy to add new acronyms.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

yay! that's the right way to do it. I tried it on Firefox, Chrome, and Edge and the bookmarklet works fine for me.

However, I just noticed that the id tags are case sensitive. With the Text Fragment, it wasn't. But since this is mainly for acronyms, and works for all browsers, this is a better solution.

Maybe we should add some of the common Vanguard and Fidelity fund tickers, maybe at the end of the page under "Ticker Symbols". That's the second (or maybe first) most common complaint about people using abbreviations.

ps. before I posted this thread, I did lookup and find this extension https://www.phpbb.com/community/viewtop ... #p14274561 which will automatically add tooltips to all words in a post that are found in the forum dictionary. But I know we don't use extensions here.
sycamore
Posts: 6360
Joined: Tue May 08, 2018 12:06 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by sycamore »

the way wrote: Sun Aug 30, 2020 7:36 pm yay! that's the right way to do it. I tried it on Firefox, Chrome, and Edge and the bookmarklet works fine for me.

However, I just noticed that the id tags are case sensitive. With the Text Fragment, it wasn't. But since this is mainly for acronyms, and works for all browsers, this is a better solution.

Maybe we should add some of the common Vanguard and Fidelity fund tickers, maybe at the end of the page under "Ticker Symbols". That's the second (or maybe first) most common complaint about people using abbreviations.

ps. before I posted this thread, I did lookup and find this extension https://www.phpbb.com/community/viewtop ... #p14274561 which will automatically add tooltips to all words in a post that are found in the forum dictionary. But I know we don't use extensions here.
Same result for me -- the javascript works in the latest Chrome, Edge, and Firefox (80.0).

Regarding the anchors being in upper case, we can use ".toUpperCase()" to convert the selected text to upper case. This should do it:

Code: Select all

javascript:void(window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+(''+window.getSelection()).toUpperCase().trim(),'','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'));
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Firefox and Chrome are working for me. I'm in Linux right now, so we're covered from that aspect.
the way wrote: Sun Aug 30, 2020 7:36 pm Maybe we should add some of the common Vanguard and Fidelity fund tickers, maybe at the end of the page under "Ticker Symbols". That's the second (or maybe first) most common complaint about people using abbreviations.
Hang on, let's slow down a bit. Remember that the wiki needs maintenance. It's simply not practical to add every ticker symbol on the planet to the page.

I understand that ticker symbols are the number 1 complaint - I fix a lot of them in newbie thread titles. (When you see brackets '[' ']' around a thread title, that's usually me fixing something.)

How do I fix them? Select the ticker symbol text in a post, then right-click "Search google for" and let google find it in a new browser tab.

So, just create another bookmarklet with the right keyword search, e.g. "Ticker" +window.getSelection()).toUpperCase().trim(). As long as you have the right keywords, it will hit every time.

There's no need to get the exact text. The reader can simply see the ticker name in the search results and copy-n-paste it into a post.

Try it for VTSAX. Google has the ticker name in big letters as the first result - it's figured out I want to see Google Finance.
the way wrote: Sun Aug 30, 2020 7:36 pm ps. before I posted this thread, I did lookup and find this extension https://www.phpbb.com/community/viewtop ... #p14274561 which will automatically add tooltips to all words in a post that are found in the forum dictionary. But I know we don't use extensions here.
Actually, we do use extensions. Here's an old example: Forum Software Updated: Show Password Strength. The one you show has not been vetted by the developers. They need to come from here: Customisation Database for phpBB version 3.3.1+.

Again, it comes down to maintenance. That extension requires an admin to maintain. It's not practical given the limited amount of resources we have.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

yeah, the right-click-to-google is really all anyone needs, so I don't know why people poo-poo the idea whenever it's mentioned. (So I actually don't think this bookmarklet will satisfy anyone either...) However the acronym page does give a simple 1-line explanation, instead of a whole page of google results, so maybe it's better.

I was thinking that the commonly used Vanguard tickers could be added to the wiki, but if not, here's a slightly modified bookmarklet that opens the specific Vanguard page or our wiki page based on the highlighted word.

Code: Select all

javascript:(function(){s=window.getSelection().toString().trim().toUpperCase(); w=window.open((['VMFXX','VMMXX','VMRXX','VUSXX','VCTXX','VMSXX','VNJXX','VYFXX','VPTXX','VFIIX','VFIJX','VIPSX','VAIPX','VIPIX','VBILX','VBIUX','VBIMX','VFITX','VFIUX','VSIGX','VIIGX','VBLAX','VBLIX','VBLLX','VUSTX','VUSUX','VLGSX','VLGIX','VMBSX','VMBIX','VBIRX','VBIPX','VBITX','VSGBX','VSGDX','VTAPX','VTSPX','VFISX','VFIRX','VSBSX','VSBIX','VBTLX','VBMPX','VBTIX','VCORX','VCOBX','VICSX','VICBX','VFICX','VFIDX','VLTCX','VLCIX','VWESX','VWETX','VSCSX','VSTBX','VFSTX','VFSUX','VFSIX','VUBFX','VUSFX','VWEHX','VWEAX','VCAIX','VCADX','VCITX','VCLAX','VWAHX','VWALX','VWITX','VWIUX','VMLTX','VMLUX','VWLTX','VWLUX','VMATX','VNJTX','VNJUX','VNYTX','VNYUX','VOHIX','VPAIX','VPALX','VWSTX','VWSUX','VTEAX','VITVX','VITWX','VRIVX','VTTWX','VITFX','VIRSX','VITLX','VTRLX','VIVLX','VILVX','VSXFX','VITRX','VTXVX','VTWNX','VTTVX','VTHRX','VTTHX','VFORX','VTIVX','VFIFX','VFFVX','VTTSX','VLXVX','VTINX','VSCGX','VASGX','VASIX','VSMGX','VBIAX','VBAIX','VPGDX','VGSTX','VTMFX','VWINX','VWIAX','VWELX','VWENX','VGWIX','VGYAX','VGWLX','VGWAX','VFIAX','VDEQX','VDADX','VDIGX','VEIPX','VEIRX','VFTAX','VFTNX','VQNPX','VGIAX','VIGAX','VIGIX','VHYAX','VIIIX','VINIX','VITPX','VITNX','VLCAX','VLISX','VMGAX','VMCTX','VMVLX','VPMCX','VPMAX','VPCCX','VRGWX','VRNIX','VRVIX','VRTTX','VSPGX','VSPVX','VTCLX','VTCIX','VTSAX','VSMPX','VITSX','VWUSX','VWUAX','VUVLX','VVIAX','VIVIX','VWNDX','VWNEX','VWNFX','VWNAX','VHCOX','VHCAX','VEXAX','VEMPX','VIEIX','VMGRX','VMGMX','VIMAX','VMCPX','VMCIX','VMVAX','VMFGX','VSPMX','VMFVX','VASVX','VSEQX','VEXPX','VEXRX','VEVFX','VRTGX','VRTIX','VRTVX','VSGNX','VSMSX','VSMVX','VSGAX','VSGIX','VSMAX','VSCPX','VSCIX','VSIAX','VSIIX','VSTCX','VTMSX','VTSIX','VFMFX','VGCIX','VGCAX','VTABX','VTIFX','VEMBX','VEGBX','VGAVX','VGIVX','VGPMX','VHGEX','VEIGX','VESGX','VTWAX','VTWIX','VTMGX','VDIPX','VTMNX','VEUSX','VEUPX','VESIX','VFWAX','VFWPX','VFWSX','VFSAX','VFSNX','VGRLX','VGRNX','VWICX','VZICX','VIAAX','VINEX','VWIGX','VWILX','VIHAX','VTRIX','VPADX','VPKIX','VTIAX','VTPSX','VTSNX','VEMRX','VMMSX','VEMAX','VEMIX','VMVFX','VMNVX','VASFX','VCMDX','VTCAX','VCDAX','VCSAX','VGENX','VGELX','VENAX','VFAIX','VGHCX','VGHAX','VHCIX','VINAX','VITAX','VMNFX','VMNIX','VMIAX','VGSLX','VGSNX','VUIAX'].includes(s) ? 'https://investor.vanguard.com/mutual-funds/profile/'+s+'#main-content' : (['EDV','BIV','VGIT','BLV','VGLT','VMBS','BSV','VTIP','VGSH','BND','VCIT','VCLT','VCSH','VTC','VTEB','VIG','ESGV','VUG','VYM','VV','MGC','MGK','MGV','VONE','VONG','VONV','VTHR','VOO','VOOG','VOOV','VTI','VTV','VXF','VO','VOT','VOE','IVOO','IVOG','IVOV','VTWO','VTWG','VTWV','VIOO','VIOG','VIOV','VB','VBK','VBR','BNDW','BNDX','VWOB','VT','VSGX','VEU','VSS','VEA','VGK','VPL','VNQI','VIGI','VYMI','VXUS','VWO','VOX','VCR','VDC','VDE','VFH','VHT','VIS','VGT','VAW','VNQ','VPU'].includes(s) ? 'https://investor.vanguard.com/etf/profile/'+s+'#main-content' : 'https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+s)),'BHHelp','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus()})();
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

I've always had Vanguard website problems when using Firefox (in Linux). All searches return an error. The ticker symbol lookup results in a Vanguard page with no fund info. :annoyed

It works fine in Chrome (in Linux).

Instead of hard-coding Vanguard tickers, how about a financial website tool? Stock Ticker Symbol Lookup - MarketWatch

It's easy to hack the URL:

Code: Select all

https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup=VTINX&Country=us&Type=All
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

I just noticed https://www.bogleheads.org/wiki/Ticker_symbol_lookup so probably there are several browser extensions of varying levels of sophistication to tackle the ticker issue. So I guess there's no point in reinventing the wheel and we can just make sure our table has any common abbrevs people like to use.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Thanks, I forgot we had that page. That wiki page was last revised in 2015 and the link to the Google webstore is broken. I linked to this post from the wiki page.

I modified the javascript to work with the CBS MarketWatch symbol lookup (only).

Rationale: New investors see nothing but a wall of text when they do a Google search. :shock: By providing results from a credible source (CBS MarketWatch), they'll have confidence knowing the name of the fund. Additionally, only a single fund will be returned which makes this easy.

Create a bookmark "Ticker symbol lookup", then insert the code below into the Location (URL) field:

Code: Select all

javascript:void(window.open('https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup='+(''+window.getSelection()).toUpperCase().trim()+'&Country=us&Type=All','','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'));
To use the bookmark:

1. Highlight the ticker symbol
2. Click on the bookmark

A new pop-up window to CBS MarketWatch will appear containing the fund name. Copy the fund name into your forum post. Done.

Note: This bookmark works on any web page, not just forum posts.

Update: See follow-up posts below.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
rossington
Posts: 1823
Joined: Fri Jun 07, 2019 2:00 am
Location: Florida

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by rossington »

LadyGeek wrote: Tue Sep 01, 2020 1:49 pm Thanks, I forgot we had that page. That wiki page was last revised in 2015 and the link to the Google webstore is broken. I linked to this post from the wiki page.

I modified the javascript to work with the CBS MarketWatch symbol lookup (only).

Rationale: New investors see nothing but a wall of text when they do a Google search. :shock: By providing results from a credible source (CBS MarketWatch), they'll have confidence knowing the name of the fund. Additionally, only a single fund will be returned which makes this easy.

Create a bookmark "Ticker symbol lookup", then insert the code below into the Location (URL) field:

Code: Select all

javascript:void(window.open('https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup='+(''+window.getSelection()).toUpperCase().trim()+'&Country=us&Type=All','','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'));
To use the bookmark:

1. Highlight the ticker symbol
2. Click on the bookmark

A new pop-up window to CBS MarketWatch will appear containing the fund name. Copy the fund name into your forum post. Done.

Note: This bookmark works on any web page, not just forum posts.
I really like the 2 bookmarklets you guys came up with, they will be really helpful and useful. You should do a sticky post letting other users know about this.
"Success is going from failure to failure without loss of enthusiasm." Winston Churchill.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

yep, this is useful - and probably safer than having to install a browser extension. (But the one Mark13 described sounded perfect - automatically create a tooltip containing a description for each ticker, without having to popup a window. Too bad it's gone.)

btw, in my last post, I changed the link a little to reuse the same popup window - otw if you don't close it right away, you end up with lots of them. Also the marketwatch lookup page seemed to redirect for stocks like AAPL but not funds like VTSAX - I just changed your URL to always go to the detail page:

Code: Select all

javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.marketwatch.com/investing/stock/'+s,'BHTicker','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus()})();
and here's the original acronym lookup bookmarklet with popup reuse too:

Code: Select all

javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+s,'BHAbbrev','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus()})();
edit: added "var" to variables just in case
Last edited by the way on Tue Sep 01, 2020 10:43 pm, edited 1 time in total.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Also note that I changed your window size to 600 wide x 500 high (ticker symbol only).

OK, so what happens when the user selects an invalid ticker? I goes to the search page. So far, so good.

Now, a user highlights the right ticker symbol, but the wrong fund. You can't back out to the search page and have to close the window and try again.

By staying in the pop-up window, they can work within the tool to figure out what was wrong.

I modified your script which reuses the same popup window, but to go to the search page. Unfortunately, I can't get it to populate the ticker symbol URL in Firefox. It works OK in Chrome.

Code: Select all

javascript:(function(){s=window.getSelection().toString().trim().toUpperCase(); w=window.open('https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup='+s+'&Country=us&Type=All','BHTicker','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
This might be the reason why: I'm getting undefined variables in a javascript syntax checker JSHint, a JavaScript Code Quality Tool, but I don't know how to fix it.

(We can have more than one bookmarklet, I'm just offering another approach.)
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
Oicuryy
Posts: 1959
Joined: Thu Feb 22, 2007 9:29 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by Oicuryy »

LadyGeek wrote: Tue Sep 01, 2020 4:00 pm This might be the reason why: I'm getting undefined variables in a javascript syntax checker JSHint, a JavaScript Code Quality Tool, but I don't know how to fix it.
Maybe use a 'var' statement to declare a variable. Does this do what you want?

Code: Select all

 javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup='+s+'&Country=us&Type=All','BHTicker','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
Ron
Money is fungible | Abbreviations and Acronyms
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

When in doubt, check for standards compliance. Yes, the URL is populated with the variable. Thanks!

However, it now goes to the fund info page in both Firefox and Chrome. The intent was to stay on the search page. I don't know what's wrong.

Update: It's working now. I'm wondering if the different javascript bookmarklets (ticker and fund info) are interfering with each other when you run more than one of them on the same page? See below.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

^^^ My fault. I was testing with stocks, not funds. the way had already figured out that the site redirects to the info page for stocks, not funds. I missed that. The bookmarklets work as advertised. In summary:

We have an acronym lookup for the wiki.*

Bookmark title: Wiki acronym lookup

Code: Select all

javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+s,'BHAbbrev','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
There are 2 ticker symbol lookups. Use whichever one you prefer.

1. This bookmarklet will go to the ticker lookup page. CBS MarketWatch will automatically redirect to the info page for stocks, but stay on the lookup page for funds. Selecting an invalid ticker symbol will stay on the ticker lookup page.*

Bookmark title: Ticker lookup

Code: Select all

javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.marketwatch.com/tools/quotes/lookup.asp?siteID=mktw&Lookup='+s+'&Country=us&Type=All','BHTicker','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
2. This bookmarklet will always go to the stock / fund info page. Selecting an invalid ticker symbol will go the the ticker lookup page.*

Bookmark title: Ticker lookup details

Code: Select all

  javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.marketwatch.com/investing/stock/'+s,'BHTicker','width=600,height=500,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
*the way's code with an added semicolon to comply with the JSHint Code Quality Tool.

=========================
To create the bookmarklet:

1. Create a bookmark.
2. Enter a title.
3. Enter the code into the Location (URL) field.
4. Save

To use:

1. Highlight an acronym or ticker symbol on any web page.
2. Click on the appropriate bookmark.

A new popup window will appear. Done.

Do this as many times as desired. Only one popup window will appear, which will overwrite the previous window.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

Great summary! I just noticed there are a few threads on this problem just in this subforum alone, including one that's 120 posts long! It included a lot of suggestions for additions to the wiki.

btw, I checked the current id tags and the following need to be double-checked. The labels always need to be all uppercase since that's how the URL is formed. And in a couple of cases, the wrong word was picked up as the anchor text.

Code: Select all

Fido
HmL
iREIT
Money
MiFID
NAREIT-
P.2FB
P.2FE
PRIIPs
Salary
S.26D
SmB
SS_2
SS_3
S.26P
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

(We're discussing the wiki page: Abbreviations and Acronyms )

My fault. I didn't capitalize the anchors when I revised the page. It was done in a spreadsheet with =concatenate(), =mid(), and a lot of manual editing. I incorporated your "bug fixes" for capitalization manually.

I also didn't realize that special characters were url encoded. Other than capitalization (and inserting a space after NAREIT), here's what I did:

Acronyms with special characters aren't working right now.

Code: Select all

P.2FB	P/B
P.2FE	P/E
S.26D	S&D
SS_2	(not used, no change)
SS_3	(not used, no change)
S.26P	S&P
The SS_2 and SS_3 anchors are extra entries for Social Security. They're not used, but I wanted an anchor to keep the rows aligned with the rest of the page.

Update: Revised post to indicate broken anchors. Fix in progress.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

Thanks! I still see the encoded strings (if you do a view source on the wiki page), so if you entered the / or &, then somehow the wiki must be encoding it when turning the markup into html? You may have to just use PE or SD, etc by itself, or trying escaping the character like "S&#38P" (not sure if that works). Also

MONEY -> MMF
SALARY -> SARSEP
and there seems to be two separate entries for SS (the main one is out of order)
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Yes, it's an encoding problem. If you look at the wikitext source and follow Template:Anchor (view source), it's using a Lua module to implement the HTML.

See: Module:Anchor

So, we just need to create a new template (Lua module) that escapes the characters correctly.

(Backgrounder: A few years ago, I spent a lot of time working in Lua. The wiki's home page section "This week in financial history" is running Lua. See: Module:ThisWeekInFinancialHistory Wikipedia uses Lua for everything, so we followed suit.)
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Topic Author
the way
Posts: 439
Joined: Sat Oct 26, 2019 6:00 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by the way »

Maybe try S&P or S&P (for S&P) and P/E (for P/E). If that doesn't work, you can try embedding html directly instead of using anchor, like

<span id="P/E"></span>

I also noticed anchor takes multiple labels, so we could do something like

{{anchor|FAANG|FANG}}

for entries which happen to contain two definitions in one or have two ways to abbreviate (e.g. PE and P/E).
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

^^^ Good point, we can work on that.
the way wrote: Fri Sep 04, 2020 4:29 pm MONEY -> MMF
SALARY -> SARSEP
and there seems to be two separate entries for SS (the main one is out of order)
Fixed. The first two are due to my spreadsheet.

See: Abbreviations and Acronyms

=============
I ended up embedding the HTML directly, but not after understanding why. No matter what I tried, special characters were never encoded correctly. Finally, I found an answer in Stack Overflow: Why wikipedia use a second html anchor when the id contains special characters So, it's both a legacy and standards compatibility issue. OK, let's hard-code.

My approach was to create a Template, which can be very loosely interpreted as a wrapper function boilerplate. Wiki editors don't understand software (except for a few...). Additionally, you want a consistent look-n-feel to the UI. So, you create Templates to hide the code and create a consistent UI.

I ended up with:

Code: Select all

{{#tag:html|<span id="P/B"/>}}
{{#tag:html|<span id="P/E"/>}}
{{#tag:html|<span id="S&D"/>}}
{{#tag:html|<span id="S&P"/>}}
The above will expand to the form:

Code: Select all

<html><span id="P/E"/></html>
which tells the wiki to interpret the enclosed content as HTML. To keep the coding short, I used a simple syntax. (You don't need a closing </span>. <span ... /> is standards compliant syntax for an element without data.)

I tried to hide the code further, but any template I created would not transclude correctly. I'm thinking it has to do with the #tag parser function I used. I can probably figure it out later, but I'll stop here for now (got stuck...).
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

the way wrote: Sat Sep 05, 2020 2:49 pm ...I also noticed anchor takes multiple labels, so we could do something like

{{anchor|FAANG|FANG}}

for entries which happen to contain two definitions in one or have two ways to abbreviate (e.g. PE and P/E).
Done. Abbreviations and Acronyms

Following the special character HTML code with the {{anchor}} template is interpreted as a nested element. It works, I'll take it.

Code: Select all

{{#tag:html|<span id="P/B"/>}}{{anchor|PB}}
Resulted in:

Code: Select all

<span id="P/B"><span id="PB"></span>
For those without a software background -

- Selecting "FANG" on a page will go to "FAANG"
- Selecting "PE" on a page will go to "P/E"
- Selecting "PB" on a page will go to "P/B"

====================================

If anyone has a suggestion on an abbreviation for the wiki, post here.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

I have added "TGH" and "MF" as acronyms. See: Abbreviations and Acronyms
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
sycamore
Posts: 6360
Joined: Tue May 08, 2018 12:06 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by sycamore »

A few suggestions:

CIT - Collective Investment Trust, https://www.bogleheads.org/wiki/Collect ... ent_Trusts
UIT - Unit Investment Trust, https://www.investopedia.com/terms/u/uit.asp

GSE - Government Sponsored Enterprise, e.g., Fannie Mae, Sallie Mae, https://www.investopedia.com/terms/g/gse.asp

IPO - Initial Public Offering, https://www.investopedia.com/terms/i/ipo.asp
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

I have added your suggestions, thanks! I used wiki references where applicable.

See: Abbreviations and Acronyms
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

FOMO has been added to the wiki. See: Abbreviations and Acronyms
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
000
Posts: 8211
Joined: Thu Jul 23, 2020 12:04 am

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by 000 »

Here are some others I've seen here:
LTCG - Long Term Capital Gains
STCG - Short Term Capital Gains
PFIC - Passive Foreign Investment Company
TINA - There Is No Alternative [to investing]
occambogle
Posts: 953
Joined: Thu Dec 12, 2019 3:58 am

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by occambogle »

Only semi-related, and I realise it would require some kind of different mechanism that I've no idea how it would work.... but has it been considered before to have some kind of lookup mechanism on stock/etf/fund tickers so you could click on any ticker and get a link/explanation to the asset in question?
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

000 wrote: Mon Sep 07, 2020 9:11 pm Here are some others I've seen here:
LTCG - Long Term Capital Gains
STCG - Short Term Capital Gains
PFIC - Passive Foreign Investment Company
TINA - There Is No Alternative [to investing]
Thanks, I have added the links: Abbreviations and Acronyms
occambogle wrote: Tue Sep 08, 2020 1:14 am Only semi-related, and I realise it would require some kind of different mechanism that I've no idea how it would work.... but has it been considered before to have some kind of lookup mechanism on stock/etf/fund tickers so you could click on any ticker and get a link/explanation to the asset in question?
Can you give an example?

The bookmark titled "Ticker lookup details" has asset info, but it might be hard to figure out. For example, VTSAX shows "Multi-cap Core" for the category.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
sycamore
Posts: 6360
Joined: Tue May 08, 2018 12:06 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by sycamore »

PPP - Purchasing Power Parity

This came up in a recent post about international bonds. I also found it explained in a BH wiki article footnote (https://www.bogleheads.org/wiki/Index_f ... ite_note-9). The first sentence might serve as an explanation: "a theory that measures prices at different locations using a common basket of goods"

And here's an investopedia reference: https://www.investopedia.com/updates/pu ... arity-ppp/
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Thanks! I used the Wikipedia article cited in the wiki (Index funds and ETFs outside of the US) because I thought it was more comprehensive than Investopedia.

PPP also means the Paycheck Protection Program. Since there can only be one unique anchor (location) on the page, I put both definitions on the same line.

See: Abbreviations and Acronyms

Or, just highlight PPP in your post and click on the bookmark.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
Peculiar_Investor
Site Admin
Posts: 2445
Joined: Thu Oct 20, 2011 12:23 am
Location: Calgary, AB 🇨🇦
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by Peculiar_Investor »

LadyGeek wrote: Thu Sep 03, 2020 2:35 pm ^^^ My fault. I was testing with stocks, not funds. the way had already figured out that the site redirects to the info page for stocks, not funds. I missed that. The bookmarklets work as advertised. In summary:

We have an acronym lookup for the wiki.*

Bookmark title: Wiki acronym lookup

Code: Select all

javascript:(function(){var s=window.getSelection().toString().trim().toUpperCase(); var w=window.open('https://www.bogleheads.org/wiki/Abbreviations_and_Acronyms#'+s,'BHAbbrev','width=700,height=300,left=0,top=0,resizable=yes,toolbar=no,location=no,scrollbars=yes,status=no,menubar=no'); w.focus();})();
Could this be rewritten to be independent of the case of the anchor text in the wiki page?

This is an external, potentially unknown requirement on how the wiki article is written that could be prone to unintended breakage.

It just happened and the wiki editors have attempted to document the the current requirement that the wiki anchors MUST be uppercase for this code to work. Since the requirement isn't internal within the wiki, it could be problematic as previously mentioned in this post.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
User avatar
ObiQuiet
Posts: 126
Joined: Sun Sep 05, 2021 12:04 pm

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by ObiQuiet »

Why not build automatic tooltips into this into the phpbb forum software? Like this add-on:
https://www.phpbb.com/community/viewtopic.php?t=584656

For at least the Vanguard and Fidelity ticker symbols. Maybe for the other abbreviations mentioned in this thread, but with a "this might mean: " prefix so that the writer's intention isn't mis-interpreted.
User avatar
LadyGeek
Site Admin
Posts: 95691
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: Bookmarklet to lookup selected word in wiki's abbreviation table

Post by LadyGeek »

Thanks for the suggestion, but that link is for a version that's no longer supported. There's nothing available which is currently supported (Customisation Database).

Additionally, we would only implement a modification if there was a significant benefit to the users.

More importantly, it takes resources to maintain those tips. For that reason, it's much easier to link to the wiki.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
Post Reply