Signal Boost bookmarklet with user name tags for more sites

Feb 14, 2019 16:58


I made a fork/update to
melannen's fork of
astolat's signal boost bookmarklet, which adds user name tags for more of the sites recognized by the DW user tag. I also made small changes to the text generated by the bookmarklet.

To use, make a blank bookmark on your browser and copy the following code into its address:

javascript:(function()%7Bvar%20postURL%3D%22https%3A%2F%2Fwww.dreamwidth.org%2Fupdate.bml%3Fevent%3D%22%3Bvar%20curURL%3Dwindow.location.href%3Bfunction%20getSelectionText()%7Bvar%20text%3D%22%22%3Bif(window.getSelection)%7Btext%3Dwindow.getSelection().toString()%7Delse%20if(document.selection%26%26document.selection.type!%3D%22Control%22)%7Btext%3Ddocument.selection.createRange().text%7Dreturn%20text%7Dfunction%20getSelectionHtml()%7Bvar%20html%3D%22%22%3Bif(typeof%20window.getSelection!%3D%22undefined%22)%7Bvar%20sel%3Dwindow.getSelection()%3Bif(sel.rangeCount)%7Bvar%20container%3Ddocument.createElement(%22div%22)%3Bfor(var%20i%3D0%2Clen%3Dsel.rangeCount%3Bi%3Clen%3Bi%2B%3D1)%7Bcontainer.appendChild(sel.getRangeAt(i).cloneContents())%7Dhtml%3Dcontainer.innerHTML%7D%7Delse%20if(typeof%20document.selection!%3D%22undefined%22)%7Bif(document.selection.type%3D%3D%22Text%22)%7Bhtml%3Ddocument.selection.createRange().htmlText%7D%7Dreturn%20html%7Dfunction%20isLocked()%7Breturn%20document.getElementsByClassName(%22security-protected%22).length%3E0%7Dfunction%20confirmBoost()%7Bvar%20doPost%3D!isLocked()%3Bif(!doPost)%7BdoPost%3Dconfirm(%22Post%20is%20access-locked.%20Continue%3F%22)%7Dreturn%20doPost%7Dfunction%20strip(s%2Cy)%7Bif(s.includes(y))%7Breturn%20s.substr(s.indexOf(y)%2B2)%7Dreturn%7Dfunction%20until(s%2Cy)%7Bif(Boolean(s)%26%26s.includes(y))%7Breturn%20s.substr(0%2Cs.indexOf(y))%7Dreturn%20s%7Dfunction%20esc(s%2Cf%2Cr)%7Bif(s.includes(f))%7Breturn%20s.replace(f%2Cr)%7Dreturn%20s%7Dfunction%20getUserName(sD%2CsN%2CfU%2CsFU%2CsSFU)%7Bvar%20sdun%3D%5B%22blogger.com%22%2C%22deadjournal.com%22%2C%22dreamwidth.org%22%2C%22insanejournal.com%22%2C%22livejournal.com%22%2C%22tumblr.com%22%2C%22wordpress.com%22%5D%3Bvar%20fun%3D%5B%22deviantart.com%22%2C%22facebook.com%22%2C%22instagram.com%22%2C%22medium.com%22%2C%22pinboard.in%22%2C%22plurk.com%22%5D%3Bif(sD!%3D'lj'%26%26sN!%3D'rossia.org')%7Bif(sN.includes('blogspot.co'))%7Breturn%20sD%7Dvar%20i%3D0%3Bwhile(i%3Csdun.length)%7Bif(sN%3D%3Dsdun%5Bi%5D)%7Bif(sD%3D%3D''%7C%7CsD%3D%3D'www')%7Breturn%7Delse%7Breturn%20sD%7D%7Di%2B%3D1%7D%7Dif(sN%3D%3D%22archiveofourown.org%22)%7Bif(Boolean(fU)%26%26fU%3D%3D'users'%26%26Boolean(sFU))%7Breturn%20sFU%7Delse%7Btry%7Bvar%20a%3Ddocument.querySelector('a%5Brel%3D%22author%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dvar%20aSplit%3Da.substr(1).split('%2F')%3Bif(aSplit%5B0%5D%3D%3D%22users%22%26%26Boolean(aSplit%5B1%5D))%7Breturn%20aSplit%5B1%5D%7D%7D%7Delse%20if(sN%3D%3D%22etsy.com%22)%7Bif(Boolean(fU)%26%26fU%3D%3D'shop'%26%26Boolean(sFU))%7Breturn%20until(sFU%2C'%3F')%7Delse%20if(Boolean(fU)%26%26fU%3D%3D'listing')%7Btry%7Bvar%20a%3Ddocument.querySelector('link%5Bhref%5E%3D%22https%3A%2F%2Fwww.etsy.com%2Fshop%2F%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dif(Boolean(strip(a%2C'%2F')))%7Breturn%20until(strip(a%2C'%2F').split('%2F')%5B2%5D%2C'%3F')%3B%7D%7D%7Delse%20if(sN%3D%3D%22fanfiction.net%22)%7Bif(Boolean(fU)%26%26fU%3D%3D'u'%26%26Boolean(sSFU))%7Breturn%20sSFU%7Delse%7Btry%7Bvar%20a%3Ddocument.querySelector('a%5Bhref%5E%3D%22%2Fu%2F%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dvar%20aSplit%3Da.substr(1).split('%2F')%3Bif(aSplit%5B0%5D%3D%3D%22u%22%26%26Boolean(aSplit%5B2%5D))%7Breturn%20aSplit%5B2%5D%7D%7D%7Delse%20if(sN%3D%3D%22medium.com%22)%7Bif(Boolean(fU)%26%26fU.charAt(0)%3D%3D'%40')%7Breturn%20fU.substr(1)%7Delse%7Btry%7Bvar%20a%3Ddocument.querySelector('link%5Brel%3D%22author%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dreturn%20a.substr(a.indexOf('%40')%2B1)%7D%7Delse%20if(sN%3D%3D%22ravelry.com%22)%7Bif(Boolean(fU)%26%26fU%3D%3D'designers')%7Breturn%20sFU%7Delse%7Btry%7Bvar%20a%3Ddocument.querySelector('a%5Bhref%5E%3D%22https%3A%2F%2Fwww.ravelry.com%2Fdesigners%2F%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dif(Boolean(strip(a%2C'%2F')))%7Breturn%20strip(a%2C'%2F').split('%2F')%5B2%5D%7D%7D%7Dvar%20i%3D0%3Bwhile(i%3Cfun.length)%7Bif(sN%3D%3Dfun%5Bi%5D%26%26Boolean(fU))%7Bif(sN%3D%3D%22instagram.com%22)%7Btry%7Bvar%20a%3Ddocument.querySelector('link%5Brel%3D%22canonical%22%5D').getAttribute('href')%7Dcatch(err)%7Breturn%7Dvar%20strippedA%3Da.substr(a.indexOf('%2F')%2B2)%3Breturn%20strippedA.split('%2F')%5B1%5D%7Dreturn%20fU%7Di%2B%3D1%7Dif(sN%3D%3D%22journalfen.com%22)%7Bif(Boolean(fU)%26%26fU%3D%3D'users'%26%26Boolean(sFU))%7Breturn%20sFU%7D%7Dif(sN%3D%3D%22last.fm%22%26%26Boolean(fU)%26%26fU%3D%3D'user'%26%26Boolean(sFU))%7Breturn%20sFU%7Dif(sD%3D%3D%22lj%22%26%26sN%3D%3D%22rossia.org%22%26%26Boolean(fU)%26%26Boolean(sFU))%7Bif(fU%3D%3D'community'%7C%7CfU%3D%3D'users')%7Breturn%20sFU%7D%7Dif(sN%3D%3D%22youtube.com%22%26%26Boolean(fU)%26%26Boolean(sFU)%26%26fU%3D%3D'user')%7Breturn%20sFU%7Dreturn%7Dfunction%20boost()%7Bvar%20selectedText%3DgetSelectionHtml()%3Bvar%20subjectText%3Bvar%20strippedURL%3Dstrip(curURL%2C'%2F')%3Bvar%20serverDomain%3DstrippedURL.split('%2F')%5B0%5D%3Bvar%20fU%3DstrippedURL.split('%2F')%5B1%5D%3Bvar%20sFU%3DstrippedURL.split('%2F')%5B2%5D%3Bvar%20sSFU%3DstrippedURL.split('%2F')%5B3%5D%3Bvar%20serverDomainParts%3DserverDomain.split('.')%3Bif(serverDomainParts.length%3C%3D1)%7Breturn%7Delse%20if(serverDomainParts.length%3D%3D2)%7Bvar%20sD%3D''%3Bvar%20sN%3DserverDomainParts%5B0%5D%2B'.'%2BserverDomainParts%5B1%5D%7Delse%20if(serverDomainParts.length%3E%3D3)%7Bvar%20sD%3DserverDomainParts%5B0%5D%3Bvar%20sN%3DserverDomainParts%5B1%5D%2B'.'%2BserverDomainParts%5B2%5D%7Dvar%20curTitle%3Ddocument.title%3Bif(sN%3D%3D%22dreamwidth.org%22%26%26curTitle.includes('%20%7C%20'))%7BcurTitle%3DcurTitle.substr(curTitle.lastIndexOf('%20%7C%20')%2B3)%7Dvar%20linkText%3D%22%22%3Bvar%20userName%3DgetUserName(sD%2CsN%2CfU%2CsFU%2CsSFU)%3Bif(Boolean(userName)%26%26userName.length%3E0)%7Bif(userName.charAt(0)%3D%3D'%40')%7Bvar%20userName%3DuserName.substr(1)%7Delse%20if(userName.substr(0%2C2)%3D%3D'u%3A')%7Bvar%20userName%3DuserName.substr(2)%7Dvar%20userTagSiteAttribute%3DsN%3Bif(sN.includes('blogspot.co'))%7Bvar%20sN%3D'blogspot.com'%3Bvar%20userTagSiteAttribute%3D'blogger.com'%7Delse%20if(sN.includes('pinterest.co'))%7Bvar%20sN%3D'pinterest.com'%3Bvar%20userTagSiteAttribute%3D'pinterest.com'%7Dvar%20linkText%3DlinkText%2B'%3Cuser%20name%3D%22'%2BuserName%2B'%22%20site%3D'%2BuserTagSiteAttribute%2B'%3E%20posted%3A%20'%7DlinkText%3DlinkText%2B'%3Cstrong%3E%3Ca%20href%3D%22'%2BcurURL%2B'%22%3E'%2Besc(curTitle%2C'%40'%2C'%26commat%3B')%2B'%3C%2Fa%3E%3C%2Fstrong%3E'%3Bif(selectedText.length%3E0)%7BlinkText%3DlinkText%2B%22%5Cn%3Cblockquote%3E%20%22%2BselectedText%2B%22%3C%2Fblockquote%3E%22%7Dif(!curTitle.includes(%22Signal%20Boost%3A%20%22))%7BsubjectText%3D%22Signal%20Boost%3A%20%22%2BcurTitle%7Delse%7BsubjectText%3DcurTitle%7DpostURL%3DpostURL%2BencodeURIComponent(linkText)%2B%22%26subject%3D%22%2BencodeURIComponent(subjectText)%3Bwindow.location%3DpostURL%7Dif(confirmBoost())%7Bboost()%7D%7D)()

The original code and my comments on it can be found here.

Update (2/14/2019 11:34 am EST): User name tags are now supported for all DW-recognized functioning platforms except diigo (I can't seem to find any pages to work on) and YouTube videos (I can't find a way to get usernames for them; YouTube user profile pages do get user-tagged, however). See examples below.

Note: I am not directly affiliated with any of the examples, and they are not chosen for content. They are more or less random examples that I got off the sites or were sitting in my history.

AO3 story:


angrymermaids posted: The Ice Between - Chapter 4 - Nibeneth (angrymermaids) - The Silmarillion and other histories of Middle-Earth - J. R. R. Tolkien [Archive of Our Own]

AO3 profile:


angrymermaids posted: Nibeneth | Archive of Our Own

Blogger.com:


yetanothermathprogrammingconsultant posted: Yet Another Math Programming Consultant: The 8-queens problem without binary variables

Deadjournal:


greenjester posted: Sanctuary's Journal

Delicious.com: The site seems defunct as far as I can tell.

Diigo.com: Unsupported, as noted above.

Deviantart:


kawacy posted: Art God by kawacy on DeviantArt

Etsy listing:


GoldPersonalized posted: Tiny Initial Bracelet-Dainty Personalized Disk | Etsy

Etsy shop:


GoldPersonalized posted: Personalized Jewelry & Handmade Necklace by GoldPersonalized

Facebook post:


EntertainmentOnFB posted: To celebrate Tropfest 2019, the world’s largest... - Entertainment on Facebook

Facebook profile:


EntertainmentOnFB posted: (92) Entertainment on Facebook - Home

FanFiction.Net story:


The-Agatha-Christiean posted: Death On The Nile - Miss Marple Chapter 1, a miss marple stories fanfic | FanFiction

FanFiction.Net profile:


The-Agatha-Christiean posted: The Agatha Christiean | FanFiction

GitHub: GitHub does not permit JavaScript bookmarklets to be used with its site.

Imzy: The site appears to be defunct.

InsaneJournal:


reijamira posted: Satin Chic - Instructions On How To Upload Mood Themes

Instagram post:


johnboyega posted: John Boyega on Instagram: “A star! Congrats @letitiawright #bafta rising star 🙌🏾”

Instagram profile:


johnboyega posted: John Boyega (@johnboyega) • Instagram photos and videos

Journalfen post:


darksumomo posted: darksumomo | ‘Elementary’ To End After 7 Seasons On CBS

Last.fm profile:


VenomInMyVeins posted: VenomInMyVeins’s Library | Last.fm

LiveJournal post:

ohnotheydidnt posted: How embarrassing! Youtuber MKBHD is exposing celebs sponsoring Android phones from iPhones - Oh No They Didn't!

Lj.rossia.org community:


ljr_news posted: LJR: новости

Medium post:


EventTeri posted: Decentralization is Not Enough - Offline Camp - Medium

Pinboard.in bookmark:


gregory31415 posted: Pinboard: Bookmark Detail

Pinterest: Pinterest does not permit JavaScript bookmarklets.

Plurk profile:


Alice posted: Alice [Alice] on Plurk - Plurk

Ravelry page:


jill-mcgee posted: Ravelry: Jill's McGee's Ravelry Downloads - patterns

Twitter.com: Twitter does not permit JavaScript bookmarklets.

Tumblr post:


aniamra posted: ɐuıɐɯɹ∀

Wordpress post:


frank posted: Speaking of Wood | rusticwoodart

YouTube profile:


monostereoJK posted: MONOMAN - YouTube

No DW-supported user tag:

BBC - Culture - How black women were whitewashed by art

Dreamwidth entry URL: https://lj-writes.dreamwidth.org/2019/02/14/bookmarklet-fork.html

social media: dreamwidth, #bafta, subject: coding, post type: resource

Previous post Next post
Up