Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. javascript: (function() {
  2. var T = {},
  3. W = [],
  4. C = 0,
  5. s, i;
  6.  
  7. function F(n) {
  8. var i, x, a, w, t = n.tagName;
  9. if (n.nodeType == 3) {
  10. a = n.data.toLowerCase().split(/[\s\(\)\:\,\.;\<\>\&\'\"]/);
  11. for (i in a)
  12. if (w = a[i]) {
  13. w = " " + w;
  14. T[w] = T[w] ? T[w] + 1 : 1;
  15. ++C;
  16. }
  17. }
  18. if (t != "SCRIPT" && t != "STYLE")
  19. for (i = 0; x = n.childNodes[i]; ++i) F(x)
  20. }
  21. F(document);
  22. for (i in T) W.push([T[i], i]);
  23. W.sort(function(a, b) {
  24. var x = b[0] - a[0];
  25. return x ? x : ((b[1] < a[1]) ? 1 : -1)
  26. });
  27. s = "<h3>" + C + " words</h3>";
  28. for (i in W) s += W[i][0] + ":" + W[i][1] + "<br>";
  29. with(open().document) {
  30. write(s);
  31. close()
  32. }
  33. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement