🏠 Home 

emoji class for DTF-markdown

emoji class

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/455678/1123020/emoji%20class%20for%20DTF-markdown.js

  1. // ==UserScript==
  2. // @name emoji class for DTF-markdown
  3. // @namespace https://github.com/TentacleTenticals
  4. // @version 0.0.1
  5. // @description emoji class
  6. // @author Tentacle Tenticals
  7. // @license MIT
  8. // @require https://greasyfork.org/scripts/455674-emoji-for-dtf-markdown/code/emoji%20for%20DTF-markdown.js?version=1123016
  9. // ==/UserScript==
  10. (function () {
  11. 'use strict';
  12. class Emoji {
  13. constructor({ path, name, url, type }) {
  14. // this.m=document.createElement('div');
  15. // this.m.className='emojiContainer';
  16. // path.appendChild(this.m);
  17. // this.name=document.createElement('p');
  18. // this.name.className='emojiName';
  19. // this.name.textContent='';
  20. // this.name.textContent=name;
  21. // this.m.appendChild(this.name);
  22. this.mask = document.createElement('div');
  23. this.mask.className = 'emojiMask';
  24. path.appendChild(this.mask);
  25. type === 'animated' ? (this.e = document.createElement('video')) : (this.e = document.createElement('img'));
  26. this.e.className = 'emoji';
  27. this.e.src = url;
  28. this.e.onclick = () => {
  29. document.querySelector(
  30. `div[class='writeComment']`
  31. ).innerHTML += `::${name}::`;
  32. document.querySelector(`div[class='emojiPicker']`).remove();
  33. };
  34. this.e.onmouseenter = () => {
  35. this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[1].textContent = `:${name}:`;
  36. type === 'animated' ? (this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[2].children[1].src =
  37. url)
  38. : (this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[2].children[0].src =
  39. url);
  40. };
  41. this.e.onmouseleave = () => {
  42. this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[1].textContent =
  43. '';
  44. type === 'animated' ? (this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[2].children[1].src =
  45. '')
  46. : (this.e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children[2].children[0].src =
  47. '');
  48. };
  49. this.mask.appendChild(this.e);
  50. }
  51. }
  52. window.EmojiPicker = class EmojiPicker {
  53. constructor(path) {
  54. if(document.getElementById('emojiPicker')) return;
  55. this.d = document.createElement('div');
  56. this.d.className = 'emojiPicker';
  57. this.d.id='emojiPicker';
  58. path.appendChild(this.d);
  59. this.title = document.createElement('div');
  60. this.title.className = 'title';
  61. this.title.textContent = 'EMOJI PICKER';
  62. this.title.onclick=() => {
  63. this.d.remove();
  64. }
  65. this.d.appendChild(this.title);
  66. this.field = document.createElement('div');
  67. this.field.className = 'emojiPicker-field';
  68. this.d.appendChild(this.field);
  69. // this.fieldPreviewName=document.createElement('div');
  70. // this.d.appendChild(this.fieldPreviewName);
  71. this.fieldPreview = document.createElement('div');
  72. this.fieldPreview.style = `
  73. display: flex;
  74. height: 70px;
  75. flex-direction: column;
  76. `;
  77. this.d.appendChild(this.fieldPreview);
  78. this.image = document.createElement('img');
  79. this.image.style = `
  80. position: relative;
  81. margin: auto;
  82. max-width: 70px;
  83. max-height: 70px;
  84. `;
  85. this.fieldPreview.appendChild(this.image);
  86. this.video = document.createElement('video');
  87. this.video.style = `
  88. position: relative;
  89. margin: auto;
  90. max-width: 70px;
  91. max-height: 70px;
  92. `;
  93. this.video.setAttribute('autoplay', '');
  94. this.fieldPreview.appendChild(this.video);
  95. this.na = document.createElement('div');
  96. this.d.appendChild(this.na);
  97. this.naLabel = document.createElement('div');
  98. this.naLabel.textContent = 'Not animated';
  99. this.naLabel.style = `
  100. text-align: center;
  101. color: white;
  102. margin-top: 5px;
  103. box-shadow: inset 0px 0px 8px 0px rgb(134 167 185);
  104. cursor: pointer;`;
  105. this.naLabel.onclick = () => {
  106. this.naLabel.nextElementSibling.classList.toggle('hidden');
  107. };
  108. this.na.appendChild(this.naLabel);
  109. this.emojiList = document.createElement('div');
  110. this.emojiList.className = 'groupList';
  111. this.na.appendChild(this.emojiList);
  112. this.a = document.createElement('div');
  113. this.d.appendChild(this.a);
  114. this.aLabel = document.createElement('div');
  115. this.aLabel.textContent = 'Animated';
  116. this.aLabel.style = `
  117. text-align: center;
  118. color: white;
  119. box-shadow: inset 0px 0px 8px 0px rgb(134 167 185);
  120. cursor: pointer;`;
  121. this.aLabel.onclick = () => {
  122. this.aLabel.nextElementSibling.classList.toggle('hidden');
  123. };
  124. this.a.appendChild(this.aLabel);
  125. this.animatedEmojiList = document.createElement('div');
  126. this.animatedEmojiList.className = 'groupList';
  127. this.a.appendChild(this.animatedEmojiList);
  128. // for(let group in emoji){
  129. // for(let emj in emoji[group]){
  130. // new Emoji({
  131. // url: emoji[group][emj],
  132. // name: emj,
  133. // path : this.emojiList
  134. // })
  135. // }
  136. // }
  137. new EmojiGroup({
  138. path: this.emojiList,
  139. type: 'not animated',
  140. });
  141. new EmojiGroup({
  142. path: this.animatedEmojiList,
  143. type: 'animated',
  144. });
  145. }
  146. }
  147. class EmojiGroup {
  148. constructor({ path, type }) {
  149. // this.eg=document.createElement('div');
  150. // type === 'animated' ? this.eg.textContent='Animated' : this.eg.textContent='Not animated';
  151. // this.eg.style=`
  152. // text-align: center;
  153. // color: white;`;
  154. // path.appendChild(this.eg);
  155. for (let group in emoji[type]) {
  156. this.main = document.createElement('div');
  157. this.main.className = 'emojiGroup';
  158. path.appendChild(this.main);
  159. this.name = document.createElement('div');
  160. this.name.className = 'groupName';
  161. this.name.textContent = group;
  162. this.main.appendChild(this.name);
  163. this.g = document.createElement('div');
  164. this.g.className = 'emojiList';
  165. this.main.appendChild(this.g);
  166. for (let emj in emoji[type][group]) {
  167. new Emoji({
  168. url: emoji[type][group][emj],
  169. name: emj,
  170. path: this.g,
  171. type: type,
  172. });
  173. }
  174. }
  175. }
  176. }
  177. })();