Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 KB | None | 0 0
  1. const script = document.createElement('script');
  2. script.type = 'text/javascript';
  3. script.async = true;
  4. script.src = 'https://rauenzi.github.io/BetterDiscordAddons/Plugins/PluginLibrary.js';
  5. document.body.appendChild(script);
  6.  
  7. const wrapper = document.createElement('div');
  8. wrapper.id = 'memerWrap';
  9. const img = new Image();
  10. img.width = 24;
  11. img.src = "https://i.imgur.com/0tZ1Sv8.png";
  12.  
  13. document.body.addEventListener('click', function(target) {
  14. if(target.target.id !== 'memesList' && target.target.parentNode.id !== 'memesList') {
  15. if (document.getElementById('memesList')) {
  16. document.body.removeChild(document.getElementById('memesList'));
  17. wrapper.style.filter = 'grayscale(100%)';
  18. }
  19. }
  20. if(target.target.parentNode.id !== 'imgWrap') {
  21. if (document.getElementById('imgWrap')) {
  22. document.body.removeChild(document.getElementById('imgWrap'));
  23. }
  24. }
  25. });
  26.  
  27. wrapper.appendChild(img);
  28. wrapper.style = "margin-right: 50px";
  29.  
  30. const wait = setTimeout(function() {
  31. clearTimeout(wait);
  32. const top = document.querySelector('svg[name=Mention]').parentNode;
  33. top.appendChild(wrapper);
  34. },100);
  35.  
  36. history.pushState = function(args) {
  37. const wait = setTimeout(function() {
  38. clearTimeout(wait);
  39. const top = document.querySelector('svg[name=Mention]').parentNode;
  40. top.appendChild(wrapper);
  41. },100);
  42. }
  43.  
  44. wrapper.style.filter = "grayscale(100%)";
  45.  
  46. const tooltips = document.getElementsByClassName('tooltips')[0];
  47. const tip = document.createElement('div');
  48. tip.setAttribute('class', 'tooltip tooltip-bottom tooltip-black');
  49. tip.innerHTML = 'Memes';
  50.  
  51. wrapper.addEventListener('mouseover', function() {
  52. wrapper.style.filter = "grayscale(0%)";
  53. wrapper.style.cursor = "pointer";
  54. const loc = wrapper.getBoundingClientRect();
  55. tip.style = `left: ${loc.left - 21}px; top: 58px;`;
  56. tooltips.appendChild(tip);
  57. });
  58. wrapper.addEventListener('mouseout', function() {
  59. if(!document.getElementById('memesList')) {
  60. wrapper.style.filter = "grayscale(100%)";
  61. }
  62. tooltips.removeChild(tip);
  63. });
  64.  
  65. const request = require('request');
  66. wrapper.addEventListener('click', function() {
  67. if(!document.getElementsByTagName("textarea").length) return;
  68. if(document.getElementsByTagName("textarea")[0].getAttribute('class').startsWith('textAreaDisabled')) return;
  69. if(document.getElementById('memesList')) {
  70. document.body.removeChild(document.getElementById('memesList'));
  71. return;
  72. }
  73.  
  74. request('https://api.imgflip.com/get_memes', function (err,a,b) {
  75. wrapper.style.filter = "grayscale(0%)";
  76. const res = JSON.parse(b);
  77. const memes = res.data.memes;
  78. const memesList = document.createElement('div');
  79. memesList.style = "position: absolute; z-index: 1000;display: flex; flex-flow: row wrap; overflow: scroll; margin-bottom: 3px; width: 218px;\
  80. height: 400px; align-items: center; justify-content: center; overflow-x: hidden; background: #353535; margin: auto; top: -102px; left: 72%; right: 0;\
  81. bottom: 0";
  82.  
  83. const css = document.createElement('style');
  84. css.type = 'text/css';
  85. css.innerHTML = `
  86. #memesList::-webkit-scrollbar {
  87. width: 12px;
  88. }
  89.  
  90. #memesList::-webkit-scrollbar-track {
  91. background: #2f3136;
  92. background-clip: padding-box;
  93. border: 3px solid #36393e;
  94. border-radius: 10px;
  95. }
  96.  
  97. #memesList::-webkit-scrollbar-thumb {
  98. background-color: #1e2124;
  99. background-clip: padding-box;
  100. border: 3px solid #1e2124;
  101. border-radius: 10px;
  102. }
  103. `
  104. css.id = "memeList_style"
  105. document.body.appendChild(css);
  106.  
  107. memesList.id = 'memesList';
  108. memes.map(function(ele) {
  109. const img = new Image();
  110. img.src = ele.url;
  111. img.id = ele.id;
  112. img.style.display = 'flex';
  113. img.height = 100;
  114. memesList.appendChild(img);
  115. });
  116. document.body.appendChild(memesList);
  117.  
  118. memesList.addEventListener('click', function(click) {
  119. if (click.target.id !== 'memesList') {
  120. click.target.height = 300;
  121. const div = document.createElement('div');
  122. const topText = document.createElement('input');
  123. const botText = document.createElement('input');
  124. const submit = document.createElement('button');
  125.  
  126. topText.setAttribute('type', 'text');
  127. botText.setAttribute('type', 'text');
  128.  
  129. submit.id = 'memeSubmit';
  130. topText.id = 'topText';
  131. botText.id = 'bottomText';
  132.  
  133. submit.innerHTML = "Finish";
  134. topText.setAttribute('placeholder', 'Top Text');
  135. botText.setAttribute('placeholder', 'Bottom Text');
  136.  
  137. div.id = 'imgWrap';
  138. click.target.style = 'position: absolute; margin: auto; top: 0; left: 0; right: 0; bottom: 0;';
  139.  
  140. document.body.appendChild(div);
  141. div.appendChild(click.target);
  142.  
  143. const wait = setTimeout(function () {
  144. clearTimeout(wait);
  145. const loc = click.target.getBoundingClientRect();
  146.  
  147. submit.style = 'position: absolute; margin: auto; left: 59.5%; z-index: 10000; top:' + (loc.bottom - 23) + 'px; height: 23px';
  148. topText.style = 'position: absolute; margin: auto; left: 43%; z-index: 10000; top:' + loc.top + 'px;';
  149. botText.style = 'position: absolute; margin: auto; left: 43%; z-index: 10000; top:' + (loc.bottom - 23) + 'px;';
  150.  
  151. div.appendChild(submit);
  152. div.appendChild(topText);
  153. div.appendChild(botText);
  154.  
  155. document.body.removeChild(memesList);
  156. },100);
  157.  
  158. submit.addEventListener('click', function () {
  159. const channel = ReactUtilities.getOwnerInstance($("form")[0]).props.channel;
  160. const queueMsg = InternalUtilities.WebpackModules.findByUniqueProperties(["enqueue"]);
  161. if (!topText.value && !botText.value) return alert('Please input at leat one field!');
  162.  
  163. request('https://api.imgflip.com/caption_image?template_id=' + click.target.id + '&username=mh5000&password=ThisIsForABot123&text0=' + topText.value + '&text1=' + botText.value, function (err,a,b) {
  164. const embed = {
  165. image: {
  166. url: JSON.parse(b).data.url
  167. }
  168. }
  169. queueMsg.enqueue({
  170. type: "send",
  171. message: {
  172. channelId: channel.id,
  173. tts: false,
  174. embed
  175. }
  176. }, function (err) {
  177. if (!err.ok) return alert('An Error Occured!');
  178. });
  179. document.body.removeChild(div);
  180. });
  181. });
  182. }
  183. });
  184. });
  185. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement