Last active
December 26, 2021 19:46
-
-
Save scottrobertson/68c186f8d7134ed2ef991b3b7cbc99a3 to your computer and use it in GitHub Desktop.
Automatically generate an email address from the current Safari page. Useful for signing up for services.
This file contains hidden or 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
// Make sure to run `yarn add tld-extract` / `npm install tld-extract` | |
const { exec } = require("child_process"); | |
var tldParser = require("tld-extract"); | |
exec( | |
"osascript -e 'tell app \"safari\" to get the url of the current tab of window 1'", | |
(_error, stdout) => { | |
try { | |
const parsedDomain = tldParser(stdout); | |
const regex = new RegExp(`.${parsedDomain.tld}`); | |
console.log(parsedDomain.domain.replace(regex, "")); | |
} catch (error) { | |
console.log("signup"); | |
return; | |
} | |
} | |
); |
This file contains hidden or 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
matches: | |
- trigger: ":EM" | |
replace: "{{domain}}@[YOUR DOMAIN HERE]" | |
vars: | |
- name: domain | |
type: script | |
params: | |
args: | |
- node | |
- path to domain_from_url.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This means you can type
:EM
while on GitHub, and it will replace that with[email protected]
.I have used this for a few years now, and it's been awesome. 1Password Masked Emails, and iCloud Hide My Email are awesome, but I find them super clunky to use compared to this.