Skip to content

Instantly share code, notes, and snippets.

@elliotttf
Last active December 13, 2015 18:19
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 elliotttf/4954716 to your computer and use it in GitHub Desktop.
Save elliotttf/4954716 to your computer and use it in GitHub Desktop.
Pro-domme bookmarklet for the lulz.
/**
* Made with ♥ by Elliott Foster
* @elliotttf
*/
var go = (function(window, document) {
function replacer(match, p1, p2, p3, offset, string) {
var ret = p1 + p2.charAt(0).toUpperCase() + p2.slice(1) + p3;
return ret;
}
return function getSelectionHtml() {
var sel, range, replacementText;
if (window.getSelection) {
sel = window.getSelection();
if (sel.rangeCount) {
range = sel.getRangeAt(0);
replacementText = range.toString().replace(/(\W+|\s+|^)(me|mine|my)(\W+|\s+|$)/g, replacer);
range.deleteContents();
range.insertNode(document.createTextNode(replacementText));
}
}
}
}(window, document));
go();
var go=function(a,b){function c(a,b,c,d){var g=b+c.charAt(0).toUpperCase()+c.slice(1)+d;return g}return function(){var d,e,f;a.getSelection&&(d=a.getSelection(),d.rangeCount&&(e=d.getRangeAt(0),f=(""+e).replace(/(\W+|\s+|^)(me|mine|my)(\W+|\s+|$)/g,c),e.deleteContents(),e.insertNode(b.createTextNode(f))))}}(window,document);go();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment