Last active
December 13, 2015 18:19
-
-
Save elliotttf/4954716 to your computer and use it in GitHub Desktop.
Pro-domme bookmarklet for the lulz.
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
/** | |
* 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(); |
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
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