Jump to content

User:Wouterstomp/Bookmarklet

From Wikipedia, the free encyclopedia

To use Wouterstomp's handy bookmarklet that uses Diberri's tool to make a wikipedia reference when used on a PubMed abstract page, do the following:

  • Create a bookmark within Internet Explorer (i.e. Favorites >> Add to Favorites...) with a suitable name.
  • Then right click on the bookmark just created and select Properties
  • Paste across to the URL box the following javascript line in its entirety: javascript:(function(){var url = location.href;var pmid = url.match(/\/pubmed\/(\d+)/);if( pmid ) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=pubmed_id&id=' + pmid[1],'add','width=800,height=300,scrollbars,resizable');})();

When the Bookmarklet is clicked whilst on a PubMed abstract page, it will open a new window with the properly formatted wikipedia citation for the article. The { {cite journal} } template may now be copied and pasted across.

Here is an experimental improved version which also works on drugbank, hgnc, pubmed central and pubchem pages:

javascript:(function(){var url = location.href;var pmid = url.match(/\/pubmed\/(\d+)/);var drugbankid = url.match(/drugs\/DB(\d+)/);var hgncid = url.match(/hgnc_id=(\d+)/);var pmcartid = url.match(/artid=(\d+)/);var pcid = url.match(/cid=(\d+)/);if(pmid) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=pubmed_id&id='%20+%20pmid[1],'add','width=800,height=300,scrollbars,resizable');if(drugbankid) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=drugbank_id&id=DB'+drugbankid[1]+'&vertical=1','add','width=800,height=300,scrollbars,resizable');if(hgncid) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?&type=hgnc_id&id='+hgncid[1]+'&vertical=1','add','width=800,height=300,scrollbars,resizable');if(pmcartid) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=pubmedcentral_id&id='+pmcartid[1],'add','width=800,height=300,scrollbars,resizable');if(pcid) w=open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=pubchem_id&id='%20+%20pmid[1],'add','width=800,height=300,scrollbars,resizable');})();

For generating a citation from a pmid selected in the text of another webpage (adapted from scripts here):

javascript:s='';function%20gS(w){for(var%20i=0;i<w.length;i++){gS(w.frames[i])};try{s+=w.window.getSelection()}catch(e){try{s+=w.document.selection.createRange().text}catch(e){s+=''}}}gS(top);{void(window.open('http://diberri.crabdance.com/cgi-bin/templatefiller/index.cgi?type=pubmed_id&id='+s,'diberri',''))}