Skip to content

Instantly share code, notes, and snippets.

@mooz
Created June 4, 2019 02:42
Show Gist options
  • Save mooz/eedfd1724d9432347110a2b320beff2c to your computer and use it in GitHub Desktop.
Save mooz/eedfd1724d9432347110a2b320beff2c to your computer and use it in GitHub Desktop.
unfill-paragraph
document.execCommand("selectAll");
var text = document.getSelection() + "";
text = text.replace(/[\n]{3,}/g, "#P@R@GR@PH#");
text = text.replace(/\n/g, " ");
text = text.replace(/[\t ]+/g, " ");
text = text.replace(/#P@R@GR@PH#/g, "\n\n");
document.execCommand("insertText", false, text);
@mooz
Copy link
Author

mooz commented Jun 4, 2019

@mooz
Copy link
Author

mooz commented Jun 4, 2019

javascript:(function()%7Bdocument.execCommand(%22selectAll%22)%3Bvar%20text%20%3D%20document.getSelection()%20%2B%20%22%22%3Btext%20%3D%20text.replace(%2F%5B%5Cn%5D%7B3%2C%7D%2Fg%2C%20%22%23P%40R%40GR%40PH%23%22)%3Btext%20%3D%20text.replace(%2F%5Cn%2Fg%2C%20%22%20%22)%3Btext%20%3D%20text.replace(%2F%5B%5Ct%20%5D%2B%2Fg%2C%20%22%20%22)%3Btext%20%3D%20text.replace(%2F%23P%40R%40GR%40PH%23%2Fg%2C%20%22%5Cn%5Cn%22)%3Bdocument.execCommand(%22insertText%22%2C%20false%2C%20text)%7D)()

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