Last active
November 25, 2019 23:13
-
-
Save LucasLarson/38333fea685fb2db75ce0b125680d7c9 to your computer and use it in GitHub Desktop.
www±: A bookmarklet to toggle between a website’s 𝚠𝚠𝚠 and 𝚗𝚘-𝚠𝚠𝚠 URIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* www± | |
* v. 0.1 | |
* | |
* Description: This is the JavaScript behind a bookmarklet to move back and | |
* forth between the 𝚠𝚠𝚠 and 𝚗𝚘-𝚠𝚠𝚠 versions of a | |
* website’s URI. | |
* | |
* Installation: See bottom | |
* | |
*/ | |
/* eslint-env browser */ | |
'use strict' | |
var url = location.href | |
if (location.href.includes('://www.')) { | |
url = url.replace('://www.', '://') | |
window.open(url, '_self') | |
} else { | |
url = url.replace('://', '://www.') | |
window.open(url, '_self') | |
} | |
// Installing bookmarklets is famously tricky (see | |
// https://mreidsma.github.io/bookmarklets/installing), but when you’re ready, | |
// the URI to enter into the bookmark’s address field is everything on the line | |
// between the /* and the */ | |
/* | |
javascript:'use%20strict';var%20url=location.href;location.href.includes('://www.')?(url=url.replace('://www.','://'),window.open(url,'_self')):(url=url.replace('://','://www.'),window.open(url,'_self')) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment