Created
February 22, 2021 22:46
-
-
Save bayleedev/f1f961e9bcd80b26041360026655dcab to your computer and use it in GitHub Desktop.
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
on randomString(aLength) | |
set randomChars to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} | |
set aString to "" | |
repeat aLength times | |
set aString to aString & some item of randomChars | |
end repeat | |
return aString | |
end randomString | |
on appName() | |
tell application "System Events" | |
set frontmostProcess to first process where it is frontmost | |
set appName to name of frontmostProcess | |
end tell | |
if appName is equal to "Safari" then | |
tell application "Safari" | |
return the URL of the current tab of the front window | |
end tell | |
else if appName is equal to "Google Chrome" then | |
tell application "Google Chrome" | |
return the URL of the active tab of the front window | |
end tell | |
end if | |
tell application appName | |
return appName & " " & the name of the front window | |
end tell | |
return appName | |
end appName | |
on appNameSlug(aLength) | |
set commandString to "~/.bin/slugify \"" & appName() & "\" | cut -c -" & aLength as string | |
return do shell script commandString | |
end appNameSlug | |
on run {input, parameters} | |
(* TODO: update the format here to meet your needs *) | |
set email to randomString(5) & "." & appNameSlug(15) & "@privaterelay.example.com" | |
tell application "System Events" to keystroke email | |
do shell script "afplay /System/Library/Sounds/Bottle.aiff" | |
return input | |
end run |
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
// ==UserScript== | |
// @name Email Generator | |
// @version 0.1 | |
// @description Type in "/email in a text or textarea field and it will update it with a randomly generated username that goes through a relay. | |
// @author You | |
// @grant none | |
// @include * | |
// ==/UserScript== | |
(function() { | |
const tmClickAudio = new Audio('data:audio/wav;charset=utf-8;base64,UklGRrgEAABXQVZFZm10IBAAAAABAAEAIlYAACJWAAABAAgAZGF0YZ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39/gICAf35+fX5/f35/gH9+f3+AgYGAgICAgYB/gIGCgH6AgYCAgIWGg4V/g4mAd3Z9enx8fX+AgYBsgKaNfnxpPHikUHy2kGWdqSZcmlh7vouMu2eBgT5SVVGCoJPguJOlZ1lXdYObs7WklZxuZGZcY2yAjpCHm4hqdWdng4KHm5KMko15b3NwbHqJfoGOfXBwbG1wdoCAg4iIgXp5c3V4eX6Bf4GJhIKEgICFioaChYaIiYeDfnx4en5/gYSBfn96eHp8f4OIiYaCgn99gIOFhoeEhIWDgH9+e31/fXp9f3x9f358e3x8fYCAgYKEhYWGhYSDg4OEhoeFhISCgH5+e3l6fH1/gICAgICAgH+Ag4SFhoeFg4B/fHx9fYCAgYGAfXx7fH+AgoaHhoaHhIKDgoCAgoGAgH9+e3p7eXh6enp+f36AgICAgIODgYSEg4SFhIKCgIB/fX5+fICBfw==') | |
const TMGenerate = { | |
random: (length) => { | |
let result = "" | |
while (result.length < length) { | |
result += (Math.random()).toString(36).substr(2) | |
} | |
return result.substr(0, length) | |
}, | |
domain: (length) => { | |
return document.domain.replace(/\.|www/g, '').substr(0, length) | |
}, | |
email: () => { | |
// TODO: update the format here to meet your needs | |
const username = TMGenerate.random(8) + '.' + TMGenerate.domain(12); | |
const domain = 'privaterelay.example.com' | |
console.assert(username.length < 64); | |
console.assert(domain.length < 250); | |
return username + '@' + domain; | |
} | |
} | |
class TMEmail { | |
constructor(intervalLength = 1000) { | |
this.active = document.body | |
setInterval(() => this.onInterval(), intervalLength) | |
} | |
onInterval () { | |
const current = document.activeElement; | |
if (this.active !== current && current) { | |
if (this.active.removeEventListener) { | |
this.active.removeEventListener('keydown', this.onKeyDown) | |
} | |
this.active = current | |
current.addEventListener('keydown', this.onKeyDown) | |
} | |
} | |
onKeyDown (e) { | |
const el = e.target; | |
const value = el.value + e.key | |
if (value === '/email') { | |
e.preventDefault() | |
tmClickAudio.play() | |
el.value = TMGenerate.email() | |
} | |
} | |
} | |
new TMEmail() | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment