Ahto Library

My library used my other scripts.

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/10922/75750/Ahto%20Library.js

  1. // Generated by CoffeeScript 1.9.3
  2. var exit, findMatches, injectScript, numberWithCommas, randInt, safeInterval, safeParseInt, setTimeout_, stringHashCode, urlMatches;
  3.  
  4. findMatches = function(selector, min, max) {
  5. var matches, ref;
  6. if (min == null) {
  7. min = 1;
  8. }
  9. if (max == null) {
  10. max = Infinity;
  11. }
  12. matches = $(selector);
  13. if ((min <= (ref = matches.length) && ref <= max)) {
  14. return matches;
  15. } else {
  16. throw Error(matches.length + " matches (expected " + min + "-" + max + ") found for selector: " + selector);
  17. }
  18. };
  19.  
  20. safeParseInt = function(s) {
  21. var n;
  22. n = parseInt(s);
  23. if (isNaN(s)) {
  24. throw new Error("Unable to parse int from \"" + s + "\"");
  25. } else {
  26. return n;
  27. }
  28. };
  29.  
  30. safeInterval = function(func, wait, times) {
  31. var interv;
  32. interv = (function(w, t) {
  33. return (function() {
  34. var e;
  35. if ((t == null) || t-- > 0) {
  36. setTimeout(interv, w);
  37. try {
  38. return func.call(null);
  39. } catch (_error) {
  40. e = _error;
  41. t = 0;
  42. throw e.toString();
  43. }
  44. }
  45. });
  46. })(wait, times);
  47. return setTimeout(interv, wait);
  48. };
  49.  
  50. stringHashCode = function(s) {
  51. var chr, hash, i, j, len;
  52. hash = 0;
  53. for (j = 0, len = s.length; j < len; j++) {
  54. i = s[j];
  55. chr = i.charCodeAt(0);
  56. hash = ((hash << 5) - hash) + chr;
  57. hash |= 0;
  58. }
  59. return hash;
  60. };
  61.  
  62. randInt = function(min, max) {
  63. return min + Math.floor(Math.random() * (max + 1 - min));
  64. };
  65.  
  66. numberWithCommas = function(n) {
  67. return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  68. };
  69.  
  70. exit = function() {
  71. throw new Error('Not an error just exiting early');
  72. };
  73.  
  74. setTimeout_ = function(wait, f) {
  75. return setTimeout(f, wait);
  76. };
  77.  
  78. injectScript = function(f) {
  79. var script, source;
  80. if (typeof f === 'function') {
  81. source = "(" + f + ")();";
  82. }
  83. script = $("<script type='application/javascript'>\n " + source + "\n</script>");
  84. $(document).append(script);
  85. return script.remove();
  86. };
  87.  
  88. urlMatches = function(regexp) {
  89. return regexp.test(window.location.href);
  90. };