Smooze

Untitled

Jul 16th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. //META{"name":"clockPlugin"}*//
  2.  
  3. //Original clock code from http://cssdeck.com/labs/minimal-css3-digital-clock
  4.  
  5. var clockPlugin = function () {};
  6.  
  7. clockPlugin.prototype.start = function () {
  8. BdApi.clearCSS("clockPluginCss");
  9. BdApi.injectCSS("clockPluginCss", '#clockPluginClock { position:absolute; color:#FFF; background:#333333; padding:0 12px 0 13px; min-width:55px; max-width:55px; z-index:100; }');
  10. var self = this;
  11. this.clock = $("<div/>", { id: "clockPluginClock" });
  12. $("body").append(this.clock);
  13.  
  14. this.pad = function(x) {
  15. return x < 10 ? '0'+x : x;
  16. };
  17.  
  18. this.ticktock = function() {
  19. var d = new Date();
  20. var h = self.pad(d.getHours());
  21. var m = self.pad(d.getMinutes());
  22. var s = self.pad(d.getSeconds());
  23. var current_time = [h,m,s].join(':');
  24. self.clock.html(current_time);
  25. };
  26.  
  27. this.ticktock12 = function() {
  28. var suffix = "AM";
  29. var d = new Date();
  30. var h = d.getHours();
  31. var m = self.pad(d.getMinutes());
  32. var s = self.pad(d.getSeconds());
  33.  
  34. if(h >= 12) {
  35. h -= 12;
  36. suffix = "PM";
  37. }
  38. if(h == 0) {
  39. h = 12;
  40. }
  41.  
  42. h = self.pad(h);
  43.  
  44. var current_time = [h,m,s].join(":") + suffix;
  45. self.clock.html(current_time);
  46. };
  47.  
  48. this.ticktock();
  49. this.interval = setInterval(this.ticktock, 1000);
  50. };
  51.  
  52. clockPlugin.prototype.load = function () {
  53.  
  54. };
  55.  
  56. clockPlugin.prototype.unload = function () {}
  57. ;
  58.  
  59. clockPlugin.prototype.stop = function () {
  60. BdApi.clearCSS("clockPluginCss");
  61. clearInterval(this.interval);
  62. this.clock.remove();
  63. };
  64.  
  65. clockPlugin.prototype.onMessage = function () {
  66.  
  67. };
  68.  
  69. clockPlugin.prototype.onSwitch = function () {
  70.  
  71. };
  72.  
  73. clockPlugin.prototype.observer = function (e) {
  74.  
  75. };
  76.  
  77. clockPlugin.prototype.getSettingsPanel = function () {
  78. return "";
  79. };
  80.  
  81. clockPlugin.prototype.getName = function () {
  82. return "Clock Plugin";
  83. };
  84.  
  85. clockPlugin.prototype.getDescription = function () {
  86. return "Adds a clock to Discord";
  87. };
  88.  
  89. clockPlugin.prototype.getVersion = function () {
  90. return "0.1.0";
  91. };
  92.  
  93. clockPlugin.prototype.getAuthor = function () {
  94. return "Jiiks";
  95. };
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. //META{"name":"ColoredVoice"}*//
  116.  
  117. var ColoredVoice = function() {};
  118. ColoredVoice.prototype.data = {};
  119. ColoredVoice.prototype.dataVersion = "1";
  120. ColoredVoice.prototype.defaultData = function() {
  121. return {
  122. version: "1"
  123. };
  124. }
  125. ColoredVoice.prototype.loadData = function() {
  126. // using the same data as ColoredTyping
  127. this.data = (localStorage.ColoredTyping) ? JSON.parse(localStorage.ColoredTyping) : {
  128. version: "0"
  129. };
  130. if (this.data.version != this.dataVersion) {
  131. // wew lad we're using a new way to save our data
  132. this.data = this.defaultData();
  133. this.saveData();
  134. };
  135. };
  136.  
  137. ColoredVoice.prototype.saveData = function() {
  138. localStorage.ColoredTyping = JSON.stringify(this.data);
  139. };
  140.  
  141. ColoredVoice.prototype.colorize = function() {
  142. var self = this;
  143. $(".channel-voice div span").each(function(index) {
  144. var username = $(this).text();
  145. $(this).css("color", self.data[username]);
  146. });
  147. };
  148.  
  149. ColoredVoice.prototype.decolorize = function() {
  150. $(".channel-voice div span").each(function(index) {
  151. $(this).css("color", "");
  152. });
  153. };
  154.  
  155. // unused
  156. ColoredVoice.prototype.load = function() {};
  157. ColoredVoice.prototype.unload = function() {};
  158. // unused
  159.  
  160. ColoredVoice.prototype.onMessage = function() {
  161. var username = $(".message .user-name").last().text();
  162. var color = $(".message .user-name").last().css("color");
  163. this.data[username] = color;
  164. this.saveData();
  165. };
  166.  
  167. ColoredVoice.prototype.start = function() {
  168. this.loadData();
  169. this.colorize();
  170. };
  171.  
  172. ColoredVoice.prototype.stop = function() {
  173. this.decolorize();
  174. };
  175.  
  176.  
  177. ColoredVoice.prototype.onSwitch = function() {
  178. var self = this;
  179. $('.member-username').each(function(index) {
  180. var username = $(this).children().html();
  181. var color = $(this).css('color');
  182. self.data[username] = color;
  183. });
  184. this.saveData();
  185. this.decolorize();
  186. this.colorize();
  187. };
  188.  
  189. ColoredVoice.prototype.observer = function(e) {
  190. //console.log(e);
  191. if (e.addedNodes.length && e.addedNodes[0].classList && e.addedNodes[0].classList.contains("channel-voice")) {
  192. this.decolorize();
  193. this.colorize();
  194. }
  195. if ((e.addedNodes.length && e.addedNodes[0].localName === "ul") ||
  196. (e.removedNodes.length && e.removedNodes[0].classList && e.removedNodes[0].classList.contains("channel-voice-states"))) {
  197. this.decolorize();
  198. this.colorize();
  199. }
  200. if (e.addedNodes.length && e.addedNodes[0].localName === "li" &&
  201. e.addedNodes[0].parentNode.className === "channel-voice-states") {
  202. this.decolorize();
  203. this.colorize();
  204. }
  205. };
  206.  
  207. ColoredVoice.prototype.getSettingsPanel = function() {
  208. return "";
  209. };
  210.  
  211. ColoredVoice.prototype.getName = function() {
  212. return "Colored Voice";
  213. };
  214.  
  215. ColoredVoice.prototype.getDescription = function() {
  216. return "Make the text color of the names in the voice channel same as role color";
  217. };
  218.  
  219. ColoredVoice.prototype.getVersion = function() {
  220. return "0.1.2";
  221. };
  222.  
  223. ColoredVoice.prototype.getAuthor = function() {
  224. return "Anxeal";
  225. };
Advertisement
Add Comment
Please, Sign In to add comment