whatimg - add [img] tags

you need to set 'upload layout' to boxed in whatimg settings

  1. // ==UserScript==
  2. // @name whatimg - add [img] tags
  3. // @namespace diff
  4. // @description you need to set 'upload layout' to boxed in whatimg settings
  5. // @include https://whatimg.com/
  6. // @include https://whatimg.com/upload.php
  7. // @require https://greasyfork.org/scripts/1003-wait-for-key-elements/code/Wait%20for%20key%20elements.js?version=2765
  8. // @version 0.2
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // using waitForKeyElements.js so this works with the drag'n'drop upload script: http://userscripts.org/scripts/show/105520
  13.  
  14. function doit() {
  15. var a = document.querySelector('textarea.input_field');
  16. var output = "";
  17. if (a) {
  18. var list = a.value.match(/(https?:\S*?\S\.(png|jpg|jpeg|gif))$/gim);
  19. for (i=0; i<list.length; i++) {
  20. output += "[img]" + list[i] + "[/img]\n";
  21. }
  22. a.value = a.value.replace(/^\s+(?=http)/gim, ""); // remove leading space from original links
  23. a.value += "\n[img] tags only:\n" + output;
  24. }
  25. }
  26.  
  27. waitForKeyElements ("textarea.input_field", doit);