Skip to content

Instantly share code, notes, and snippets.

@ozh
Last active June 8, 2021 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozh/09564ca271f921b9804b6410584ebbaa to your computer and use it in GitHub Desktop.
Save ozh/09564ca271f921b9804b6410584ebbaa to your computer and use it in GitHub Desktop.
email + website @ gmail.com bookmarklet

Will populate active input field with "turlututu+<domain name>@gmail.com"

Code:

javascript:(function()%7Bvar%20w%20%3D%20window.location.hostname.replace(%2F%5Ewww%5C.%2F%2C%20'')%3Bw%20%3D%20w.replace(%2F%5C..%7B2%2C3%7D%24%2F%2C%20'').replace(%2F%5E.%2B%5C.%2F%2C%20'')%3Bvar%20i%20%3D%20document.activeElement%3Bif%20(i.tagName%20%3D%3D%20%22INPUT%22%20%7C%7C%20i.tagName%20%3D%3D%20%22TEXTAREA%22)%20%7Bi.value%20%3D%20'turlututu%2B'%20%2B%20w%20%2B%20'%40gmail.com'%3B%7D%7D)()

Expanded:

javascript: (function() {
    var w = window.location.hostname.replace(/^www\./, '');
    w = w.replace(/\..{2,3}$/, '').replace(/^.+\./, '');
    var i = document.activeElement;
    if (i.tagName == "INPUT" || i.tagName == "TEXTAREA") {
        i.value = 'turlututu+' + w + '@gmail.com';
    }
})()
@ozh
Copy link
Author

ozh commented Jun 8, 2021

JS code to bookmarklet with https://mrcoles.com/bookmarklet/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment