code_junkie

How can you find all the IP addresses in a selected block of text with a javascript bookmarklet?

Nov 10th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. javascript:ipAddresses=document.getSelection().match(/bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/g).join("<br>");newWindow=window.open('', 'IP Addresses in Selection', 'innerWidth=200,innerHeight=300,scrollbars');newWindow.document.write(ipAddresses)
  2.  
  3. javascript:alert(
  4. document.getSelection().match(/bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/g)
  5. .join("n"))
  6.  
  7. /bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/
  8. /^([1-9][0-9]{0,2})+.([1-9][0-9]{0,2})+.([1-9][0-9]{0,2})+.([1-9][0-9]{0,2})+$/
  9.  
  10. javascript:document.write(document.getSelection().match(/bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/g))
  11.  
  12. CmdUtils.CreateCommand({
  13. name: "findip",
  14. preview: function( pblock ) {
  15. var msg = 'IP Addresses Found<br/><br/> ';
  16. ips = CmdUtils.getHtmlSelection().match(/bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/g);
  17. if(ips){
  18. msg += ips.join("<br/>n");
  19. }else{
  20. msg += 'None';
  21. }
  22. pblock.innerHTML = msg;
  23. },
  24.  
  25. execute: function() {
  26. ips = CmdUtils.getHtmlSelection().match(/bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/g);
  27. if(ips){
  28. CmdUtils.setSelection(ips.join("<br/>n"));
  29. }
  30. }
  31. })
Add Comment
Please, Sign In to add comment