Last active
May 15, 2021 08:49
-
-
Save aquilax/88913aea1a8829aef6d4b4a99ca8802a to your computer and use it in GitHub Desktop.
Sort lines bookmarklet
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
javascript:(function(){ | |
var container = document.createElement('div'); | |
container.setAttribute('style', 'position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9999'); | |
var textarea = document.createElement('textarea'); | |
textarea.setAttribute('style', 'width:99%; height: 20em'); | |
var close = document.createElement('button'); | |
close.textContent = 'Close' | |
close.addEventListener("click", function() { | |
container.remove(); | |
}); | |
var sort = document.createElement('button'); | |
sort.textContent = 'Sort' | |
sort.addEventListener("click", function() { | |
textarea.value = textarea.value.split("\n").sort().join("\n"); | |
}); | |
container.appendChild(textarea); | |
container.appendChild(sort); | |
container.appendChild(close); | |
document.body.insertBefore(container, document.body.firstChild); | |
})(); |
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
<a href="javascript:(function(){var b=document.createElement('div');b.setAttribute('style','position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9999');var a=document.createElement('textarea');a.setAttribute('style','width:99%; height: 20em');var d=document.createElement('button');d.textContent='Close';d.addEventListener('click',function(){b.remove()});var c=document.createElement('button');c.textContent='Sort';c.addEventListener('click',function(){a.value=a.value.split('\n').sort().join('\n')});b.appendChild(a);b.appendChild(c);b.appendChild(d);document.body.insertBefore(b,document.body.firstChild)})();">Sort Lines</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment