Vote Explosion Effect (o_o)

Robi BUUUM.

当前为 2016-02-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Vote Explosion Effect (o_o)
  3. // @namespace voteexplosion
  4. // @description Robi BUUUM.
  5. // @include http://*.wykop.pl/*
  6. // @include http://*.mirkoczat.pl/*
  7. // @version 2.2
  8. // ==/UserScript==
  9.  
  10. // 88
  11. // ""
  12. //
  13. // ,adPPYba, 8b,dPPYba, ,adPPYba, 88 ,adPPYba,
  14. // a8" "8a 88P' "8a a8" "" 88 a8P_____88
  15. // 8b d8 88 d8 8b 88 8PP"""""""
  16. // "8a, ,a8" 88b, ,a8" "8a, ,aa 88 "8b, ,aa
  17. // `"YbbdP"' 88`YbbdP"' `"Ybbd8"' 88 `"Ybbd8"'
  18. // 88 ,88
  19. // 88 888P"
  20.  
  21.  
  22.  
  23.  
  24. var options = {
  25. particleSpread: 150,
  26. particleCount: 20
  27. };
  28.  
  29. if(localStorage.getItem("particleSpread")) {
  30. options.particleSpread = localStorage.getItem("particleSpread");
  31. }
  32.  
  33. if(localStorage.getItem("particleCount")) {
  34. options.particleCount = localStorage.getItem("particleCount");
  35. }
  36.  
  37.  
  38. // 88
  39. // ,d 88
  40. // 88 88
  41. // ,adPPYba, MM88MMM 8b d8 88 ,adPPYba,
  42. // I8[ "" 88 `8b d8' 88 a8P_____88
  43. // `"Y8ba, 88 `8b d8' 88 8PP"""""""
  44. // aa ]8I 88, `8b,d8' 88 "8b, ,aa
  45. // `"YbbdP"' "Y888 Y88' 88 `"Ybbd8"'
  46. // d8'
  47. // d8'
  48.  
  49.  
  50. $('head').append('<style type="text/css">\
  51. .particleGreen {\
  52. color: #3b915f;\
  53. }\
  54. .particleGray {\
  55. color: #999;\
  56. }\
  57. .particleGolden {\
  58. color: #c7a054;\
  59. }\
  60. .particleRed {\
  61. color: #c0392b;\
  62. }\
  63. .particle {\
  64. position: absolute;\
  65. pointer-events: none;\
  66. z-index: 696969;\
  67. transition: 1.5s all cubic-bezier(0.000, 0.895, 0.985, 1.005);\
  68. }\
  69. .particle i.fa {\
  70. font-size: 1.5rem;\
  71. }\
  72. .votersContainer {\
  73. min-height: 18px;\
  74. margin-bottom: 6px;\
  75. }\
  76. body li.entry ul.responsive-menu b a.affect {\
  77. color: #c0392b !important;\
  78. }\
  79. body li.entry .lcontrast:hover ul.responsive-menu b a.affect {\
  80. color: #c0392b !important;\
  81. }\
  82. </style>');
  83.  
  84.  
  85.  
  86. // ad88 88 88
  87. // d8" 88 ""
  88. // 88 88
  89. // MM88MMM 88 88 8b,dPPYba, 88 ,d8 ,adPPYba, 88 ,adPPYba,
  90. // 88 88 88 88P' `"8a 88 ,a8" a8" "" 88 a8P_____88
  91. // 88 88 88 88 88 8888[ 8b 88 8PP"""""""
  92. // 88 "8a, ,a88 88 88 88`"Yba, "8a, ,aa 88 "8b, ,aa
  93. // 88 `"YbbdP'Y8 88 88 88 `Y8a `"Ybbd8"' 88 `"Ybbd8"'
  94. // ,88
  95. // 888P"
  96.  
  97.  
  98.  
  99. function getParticlePosition(x, y, direction) {
  100.  
  101. 'use strict';
  102.  
  103. var randomX = x - Math.floor((Math.random() * options.particleSpread) + 1 - (options.particleSpread / 2)),
  104. randomY = y - Math.floor((Math.random() * options.particleSpread) + 1 - (options.particleSpread / 2)),
  105. randomDirection = Math.floor((Math.random() * 100) + 1);
  106.  
  107. if(direction == 'down') {
  108. randomY = randomY + randomDirection;
  109. } else {
  110. randomY = randomY - randomDirection;
  111. }
  112.  
  113. return [randomX, randomY];
  114. }
  115.  
  116. function randomRotate() {
  117. return Math.floor((Math.random() * 360) + 1);
  118. }
  119.  
  120. function randomZoom() {
  121. return 2 - (Math.floor((Math.random() * 200) + 1) / 100);
  122. }
  123.  
  124. function particleExplode(iconClass, colorClass, direction, click) {
  125.  
  126. 'use strict';
  127.  
  128. var body = $('body'),
  129. posX = click.pageX,
  130. posY = click.pageY,
  131. particleRandomClass = 'particle_' + Math.random().toString(36).substring(4),
  132. particlesArray = [],
  133. particle = '';
  134.  
  135. for (var i = 0; i < options.particleCount; i++) {
  136. var particleID = 'particle_' + Math.random().toString(36).substring(4),
  137. particleClass = 'particle ' + colorClass + ' ' + particleRandomClass,
  138. particleStyle = 'top: ' + posY + 'px; left: ' + posX + 'px;',
  139. particle = particle + '<div class="' + particleClass + '" style="' + particleStyle + '" id="' + particleID + '"><i class="fa ' + iconClass + '"></i></div>';
  140.  
  141. particlesArray[i] = particleID;
  142. }
  143.  
  144. body.append(particle);
  145.  
  146. for (var i = 0; i < options.particleCount; i++) {
  147. var particlePosition = getParticlePosition(posX, posY, direction),
  148. rotate = randomRotate(),
  149. zoom = randomZoom(),
  150. fadeOutTime = 300 + Math.floor((Math.random() * 1200) + 1);
  151. $('#' + particlesArray[i])
  152. .fadeIn(1, function(){
  153. $(this)
  154. .css('top', particlePosition[1] + 'px')
  155. .css('left', particlePosition[0] + 'px')
  156. .css('transform', 'rotate(' + rotate + 'deg) scale(' + randomZoom() + ')')
  157. .fadeOut(fadeOutTime, function(){
  158. $(this).remove();
  159. });
  160. });
  161. }
  162. }
  163.  
  164.  
  165.  
  166.  
  167. // ad88 88
  168. // d8" ""
  169. // 88
  170. // MM88MMM 88 8b, ,d8 8b d8
  171. // 88 88 `Y8, ,8P' `8b d8'
  172. // 88 88 )888( `8b d8'
  173. // 88 88 ,d8" "8b, `8b,d8'
  174. // 88 88 8P' `Y8 Y88'
  175. // d8'
  176. // d8'
  177.  
  178.  
  179. if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
  180. // fajerfoksy chodzą źle, trzeba zmniejszyć liczbę cząsteczków :<
  181. options.particleCount = 10;
  182. }
  183.  
  184.  
  185. // 88,dPYba,,adPYba, ,adPPYba, 8b,dPPYba, 88 88
  186. // 88P' "88" "8a a8P_____88 88P' `"8a 88 88
  187. // 88 88 88 8PP""""""" 88 88 88 88
  188. // 88 88 88 "8b, ,aa 88 88 "8a, ,a88
  189. // 88 88 88 `"Ybbd8"' 88 88 `"YbbdP'Y8
  190.  
  191.  
  192. $('.dropdown.right.m-hide div ul li:last').before('<li><a href="#" title="" id="openSettingsWindow"><i class="fa fa-wrench"></i> <span>opcje skryptu</span></a></li>');
  193.  
  194. $(document).on('click', '#openSettingsWindow', function(){
  195.  
  196. var userNick = $('.dropdown-show.auto > img.avatar').attr('alt');
  197.  
  198. if(localStorage.getItem("particleSpread")) {
  199. var particleSpread = localStorage.getItem("particleSpread");
  200. } else {
  201. var particleSpread = options.particleSpread;
  202. }
  203.  
  204. if(localStorage.getItem("particleCount")) {
  205. var particleCount = localStorage.getItem("particleCount");
  206. } else {
  207. var particleCount = options.particleCount;
  208. }
  209.  
  210. var settingsForm = '<br>\
  211. <p>Tutaj możesz zmienić ustawienia skryptu.</p>\
  212. <br>\
  213. <label for="particleSpread">wielkość wybuchu (px)</label>\
  214. <input type="text" class="form-control" id="particleSpread" value="' + particleSpread + '">\
  215. <br>\
  216. <br>\
  217. <label for="particleCount">liczba cząsteczek (px)</label>\
  218. <input type="text" class="form-control" id="particleCount" value="' + particleCount + '">\
  219. <br>\
  220. <div style="margin: 15px; text-align: center;" id="msgContainer">Zmiany zapisują się automatycznie.</div>\
  221. <div style="text-align: center;" id="msgContainer">\
  222. <input class="bigred closepreview" style="text-align:center; cursor: pointer;" type="button" value="zapisz ustawienia" id="">\
  223. </div>',
  224. settingsPropaganda = '<br><hr><br>\
  225. <img src="http://xs.cdn03.imgwykop.pl/c3397992/Dreszczyk_sBtjObQZ5c,q48.jpg" style="float:left; margin-right: 10px;">Cześć ' + userNick + '. Tutaj twórca tego skryptu, @Dreszczyk. Jeżeli chcesz podziękować z ten skrypt, to wiedz, że bardzo lubie <a href="http://www.wykop.pl/ludzie/Dreszczyk/">subskrybowanie mojego profilu</a>.',
  226. settingsWindow = '<div id="violationContainer">\
  227. <div class="overlay" style="display: block;"></div>\
  228. <div id="zgloszenie" style="display: none;" class="normal m-set-fullwidth m-reset-top m-reset-margin m-reset-left">\
  229. <form id="scriptSettings">\
  230. <div class="header">\
  231. <a href="#" title="zamknij" class="fright close"><span class="icon inlblk mini closepreview"><i class="fa fa-times"></i></span></a>\
  232. <span class="title">Vote Explosion Script - ustawienia</span>\
  233. </div>\
  234. <div class="view" style="max-height: initial;">' + settingsForm + '' + settingsPropaganda + '</div>\
  235. </form>\
  236. </div>\
  237. </div>';
  238.  
  239. $('body').prepend(settingsWindow).find('#zgloszenie').fadeIn();
  240. });
  241.  
  242. $(document).on('click', 'div.overlay', function(){
  243. $('#violationContainer').remove();
  244. });
  245.  
  246. $(document).on('change', '#scriptSettings input', function(){
  247. localStorage.setItem($(this).attr('id'), $(this).val());
  248. options[$(this).attr('id')] = $(this).val();
  249. $('#msgContainer').html('Zmiany zapisują się automatycznie - <b>zapisane</b>.');
  250. });
  251.  
  252.  
  253. // 88
  254. // 88
  255. // 88
  256. // 8b,dPPYba, 88 88 88 ,adPPYba, 8b d8
  257. // 88P' "8a 88 88 88 I8[ "" `8b d8'
  258. // 88 d8 88 88 88 `"Y8ba, `8b d8'
  259. // 88b, ,a8" 88 "8a, ,a88 aa ]8I `8b,d8'
  260. // 88`YbbdP"' 88 `"YbbdP'Y8 `"YbbdP"' Y88'
  261. // 88 d8'
  262. // 88 d8'
  263.  
  264.  
  265. $('body').on('click', 'a.button.mikro.ajax', function (click) {
  266. if($(this).parent().find('b.voted.plus').length) {
  267. particleExplode('fa-minus', 'particleRed', 'down', click);
  268. } else {
  269. particleExplode('fa-plus', 'particleGreen', 'up', click);
  270. }
  271. });
  272.  
  273. $('body').on('click', 'div.avatar-plus img', function (click) {
  274. particleExplode('fa-plus', 'particleGreen', 'up', click);
  275. });
  276.  
  277.  
  278. // 88
  279. // 88
  280. // 88
  281. // ,adPPYba, 88 88 88,dPPYba,
  282. // I8[ "" 88 88 88P' "8a
  283. // `"Y8ba, 88 88 88 d8
  284. // aa ]8I "8a, ,a88 88b, ,a8"
  285. // `"YbbdP"' `"YbbdP'Y8 8Y"Ybbd8"'
  286.  
  287.  
  288. $('body').on('click', 'a[title="Dodaj do obserwowanych"]', function (click) {
  289. particleExplode('fa-eye', 'particleGreen', 'up', click);
  290. });
  291.  
  292. $('body').on('click', 'a[title="Usuń z obserwowanych"]', function (click) {
  293. particleExplode('fa-eye-slash', 'particleGray', 'down', click);
  294. });
  295.  
  296.  
  297. // 88 88
  298. // 88 ""
  299. // 88
  300. // ,adPPYb,88 88 ,adPPYb,d8
  301. // a8" `Y88 88 a8" `Y88
  302. // 8b 88 88 8b 88
  303. // "8a, ,d88 88 "8a, ,d88
  304. // `"8bbdP"Y8 88 `"YbbdP"Y8
  305. // aa, ,88
  306. // "Y8bbdP"
  307.  
  308.  
  309. $('body').on('click', '.diggbox span', function (click) {
  310. if($(this).parent().parent().hasClass('digout')) {
  311. particleExplode('fa-thumbs-down', 'particleRed', 'down', click);
  312. } else {
  313. particleExplode('fa-thumbs-up', 'particleGreen', 'up', click);
  314. }
  315. });
  316.  
  317.  
  318. // ad88 88 88
  319. // d8" 88 88
  320. // 88 88 88
  321. // MM88MMM ,adPPYba, 88 88 ,adPPYba, 8b db d8
  322. // 88 a8" "8a 88 88 a8" "8a `8b d88b d8'
  323. // 88 8b d8 88 88 8b d8 `8b d8'`8b d8'
  324. // 88 "8a, ,a8" 88 88 "8a, ,a8" `8bd8' `8bd8'
  325. // 88 `"YbbdP"' 88 88 `"YbbdP"' YP YP
  326.  
  327.  
  328. $('body').on('click', 'a[title="Dodaj do obserwowanych"]', function (click) {
  329. particleExplode('fa-eye', 'particleGreen', 'down', click);
  330. });
  331.  
  332. $('body').on('click', 'a[title="Usuń z obserwowanych"]', function (click) {
  333. particleExplode('fa-eye-crossed', 'particleGray', 'up', click);
  334. });
  335.  
  336. // ad88
  337. // d8"
  338. // 88
  339. // MM88MMM ,adPPYYba, 8b d8
  340. // 88 "" `Y8 `8b d8'
  341. // 88 ,adPPPPP88 `8b d8'
  342. // 88 88, ,88 `8b,d8'
  343. // 88 `"8bbdP"Y8 "8"
  344.  
  345. $('body').on('click', 'li.entry .responsive-menu a.affect.ajax, li.iC .responsive-menu a.affect.ajax', function (click) {
  346. if($(this).parent().is('b')) {
  347. particleExplode('fa-heart-o', 'particleGray', 'down', click);
  348. } else {
  349. particleExplode('fa-heart', 'particleRed', 'up', click);
  350. }
  351. });
  352.  
  353.  
  354. // 88 88 88
  355. // 88 88 88
  356. // 88 88 88
  357. // 88,dPPYba, 88 ,adPPYba, ,adPPYba, 88 ,d8
  358. // 88P' "8a 88 a8" "8a a8" "" 88 ,a8"
  359. // 88 d8 88 8b d8 8b 8888[
  360. // 88b, ,a8" 88 "8a, ,a8" "8a, ,aa 88`"Yba,
  361. // 8Y"Ybbd8"' 88 `"YbbdP"' `"Ybbd8"' 88 `Y8a
  362.  
  363.  
  364. $('body').on('click', 'a[title="zablokuj użytkownika"]', function (click) {
  365. particleExplode('fa-lock', 'particleRed', 'down', click);
  366. });
  367.  
  368. $('body').on('click', 'a[title="odblokuj użytkownika"]', function (click) {
  369. particleExplode('fa-unlock', 'particleGray', 'up', click);
  370. });