Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Shoutbox Ignore
  3. // @namespace sbignore
  4. // @include *rune-server.org/forum.php
  5. // @include *rune-server.org/forum.php#*
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js
  7. // @require http://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js
  8. // @version 1
  9. // ==/UserScript==
  10.  
  11. InfernoShoutbox.ignoredUsers = new Array();
  12.  
  13. InfernoShoutbox.idlecheck = function () {}
  14.  
  15. InfernoShoutbox.add_ignore = function (username) {
  16. username = PHP.trim(username.toLowerCase());
  17. InfernoShoutbox.ignoredUsers.push(username);
  18. InfernoShoutbox.update_ignore_cookie();
  19. }
  20.  
  21. InfernoShoutbox.del_ignore = function (username) {
  22. $.each(InfernoShoutbox.ignoredUsers, function (index) {
  23. if (this.toLowerCase() == username.toLowerCase()) {
  24. InfernoShoutbox.ignoredUsers.splice(index, 1);
  25. InfernoShoutbox.update_ignore_cookie();
  26. }
  27. });
  28. }
  29.  
  30. InfernoShoutbox.update_ignore_cookie = function () {
  31. $.cookie('sb_ignored_users', InfernoShoutbox.ignoredUsers.toString(), {
  32. expires: 365
  33. });
  34. }
  35.  
  36. InfernoShoutbox.load_ignore_users_from_cookie = function () {
  37. if (typeof $.cookie('sb_ignored_users') == "undefined") {
  38. $.cookie('sb_ignored_users', '', {
  39. expires: 365
  40. });
  41. }
  42.  
  43. $.each($.cookie('sb_ignored_users').split(','), function () {
  44. if (this.length > 0)
  45. InfernoShoutbox.ignoredUsers.push(this.toLowerCase());
  46. });
  47.  
  48. if (InfernoShoutbox.ignoredUsers.toString().length > 0)
  49. InfernoShoutbox.show_notice('Ignored users: ' + InfernoShoutbox.ignoredUsers.toString());
  50. }
  51.  
  52. InfernoShoutbox.post_shout = function (message) {
  53. InfernoShoutbox.shout.ajax = new vB_AJAX_Handler(true);
  54. InfernoShoutbox.shout.ajax.onreadystatechange(InfernoShoutbox.shout_posted);
  55. InfernoShoutbox.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message) + '&');
  56. }
  57.  
  58. InfernoShoutbox.shout = function () {
  59. if (InfernoShoutbox.posting_shout) {
  60. InfernoShoutbox.show_notice('A previous message is still being submitted.');
  61. return false;
  62. }
  63. message = InfernoShoutbox.editor.value;
  64.  
  65. if (message.indexOf("/") == 0) {
  66. var command = message.substring(1);
  67.  
  68. if (command.indexOf("ignore") == 0) {
  69. InfernoShoutbox.add_ignore(command.substring(7));
  70. InfernoShoutbox.show_notice(command.substring(7) + " added to ignore list. /unignore " + command.substring(7) + " to unignore user.");
  71. } else if (command.indexOf("unignore") == 0) {
  72. InfernoShoutbox.del_ignore(command.substring(9));
  73. InfernoShoutbox.show_notice("Unignored " + command.substring(9));
  74. } else {
  75. InfernoShoutbox.show_notice('Command "' + command + ' does not exist."');
  76. }
  77. } else {
  78. message = InfernoShoutbox.shout_params.prefix + message + InfernoShoutbox.shout_params.suffix;
  79.  
  80. InfernoShoutbox.posting_shout = true;
  81. InfernoShoutbox.set_loader('');
  82. InfernoShoutbox.post_shout(message);
  83. }
  84.  
  85. InfernoShoutbox.clear();
  86. return false;
  87. }
  88.  
  89. InfernoShoutbox.fetch_shouts = function () {
  90. if (InfernoShoutbox.posting_shout && !InfernoShoutbox.force_fetch) {
  91. if (InfernoShoutbox.failure_count('posting_shout')) {
  92. InfernoShoutbox.posting_shout = false;
  93. }
  94.  
  95. return false;
  96. }
  97.  
  98. if (InfernoShoutbox.fetching_shouts) {
  99. if (InfernoShoutbox.failure_count('fetching_shouts')) {
  100. InfernoShoutbox.fetching_shouts = false;
  101. }
  102.  
  103. return false;
  104. }
  105.  
  106. if (InfernoShoutbox.idle && InfernoShoutbox.loaded) {
  107. InfernoShoutbox.show_notice('You are currently idle in the shoutbox. Click <a href="?" onclick="return InfernoShoutbox.unidle();">here</a> to un-idle yourself.');
  108. clearTimeout(InfernoShoutbox.kill_notice); // Don't hide this notice
  109. return false;
  110. }
  111.  
  112. InfernoShoutbox.fetching_shouts = true;
  113. InfernoShoutbox.force_fetch = false;
  114. InfernoShoutbox.loaded = true;
  115.  
  116. InfernoShoutbox.set_loader('');
  117.  
  118. $.get("infernoshout.php", 'do=messages' + ((InfernoShoutbox.detached) ? '&detach=true' : '') + '&fetchtype=' + InfernoShoutbox.shout_params.fetchtype + '&', function (data) {
  119. resp = data.split(InfernoShoutbox.parsebreaker);
  120. object = $('<div>').html(resp[0]);
  121.  
  122. object.find('a[href="#"]').each(function () {
  123. obj = $(this);
  124. $.each(InfernoShoutbox.ignoredUsers, function () {
  125. if (PHP.trim(obj.text().toLowerCase()) == this.toLowerCase()) {
  126. obj.parents('div').remove();
  127. }
  128. });
  129. });
  130.  
  131. InfernoShoutbox.update_shouts(object.html());
  132. if (resp[1]) {
  133. InfernoShoutbox.activity.innerHTML = resp[1];
  134. }
  135. // Posting a shout now finishes here, when shouts have been refetched
  136. if (InfernoShoutbox.posting_shout) {
  137. InfernoShoutbox.posting_shout = false;
  138. }
  139.  
  140. InfernoShoutbox.set_loader('none');
  141. InfernoShoutbox.fetching_shouts = false;
  142. });
  143. }
  144.  
  145. InfernoShoutbox.load_ignore_users_from_cookie();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement