Advertisement
Guest User

Script SPAM MP JVC

a guest
Mar 26th, 2019
1,455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Spam MP JVC
  3. // @namespace http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm
  4. // @version 0.0.3
  5. // @description Spam MP JVC
  6. // @author QLF
  7. // @match http://www.jeuxvideo.com/*
  8. // @grant none
  9. // @require http://code.jquery.com/jquery-latest.js
  10.  
  11. // ==/UserScript==
  12.  
  13. //COOKIE
  14. (function (factory) {
  15. if (typeof define === 'function' && define.amd) {
  16. // AMD
  17. define(['jquery'], factory);
  18. } else if (typeof exports === 'object') {
  19. // CommonJS
  20. factory(require('jquery'));
  21. } else {
  22. // Browser globals
  23. factory(jQuery);
  24. }
  25. }(function ($) {
  26.  
  27. var pluses = /\+/g;
  28.  
  29. function encode(s) {
  30. return config.raw ? s : encodeURIComponent(s);
  31. }
  32.  
  33. function decode(s) {
  34. return config.raw ? s : decodeURIComponent(s);
  35. }
  36.  
  37. function stringifyCookieValue(value) {
  38. return encode(config.json ? JSON.stringify(value) : String(value));
  39. }
  40.  
  41. function parseCookieValue(s) {
  42. if (s.indexOf('"') === 0) {
  43. // This is a quoted cookie as according to RFC2068, unescape...
  44. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  45. }
  46.  
  47. try {
  48. // Replace server-side written pluses with spaces.
  49. // If we can't decode the cookie, ignore it, it's unusable.
  50. // If we can't parse the cookie, ignore it, it's unusable.
  51. s = decodeURIComponent(s.replace(pluses, ' '));
  52. return config.json ? JSON.parse(s) : s;
  53. } catch(e) {}
  54. }
  55.  
  56. function read(s, converter) {
  57. var value = config.raw ? s : parseCookieValue(s);
  58. return $.isFunction(converter) ? converter(value) : value;
  59. }
  60.  
  61. var config = $.cookie = function (key, value, options) {
  62.  
  63. // Write
  64.  
  65. if (value !== undefined && !$.isFunction(value)) {
  66. options = $.extend({}, config.defaults, options);
  67.  
  68. if (typeof options.expires === 'number') {
  69. var days = options.expires, t = options.expires = new Date();
  70. t.setTime(+t + days * 864e+5);
  71. }
  72.  
  73. return (document.cookie = [
  74. encode(key), '=', stringifyCookieValue(value),
  75. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  76. options.path ? '; path=' + options.path : '',
  77. options.domain ? '; domain=' + options.domain : '',
  78. options.secure ? '; secure' : ''
  79. ].join(''));
  80. }
  81.  
  82. // Read
  83.  
  84. var result = key ? undefined : {};
  85.  
  86. // To prevent the for loop in the first place assign an empty array
  87. // in case there are no cookies at all. Also prevents odd result when
  88. // calling $.cookie().
  89. var cookies = document.cookie ? document.cookie.split('; ') : [];
  90.  
  91. for (var i = 0, l = cookies.length; i < l; i++) {
  92. var parts = cookies[i].split('=');
  93. var name = decode(parts.shift());
  94. var cookie = parts.join('=');
  95.  
  96. if (key && key === name) {
  97. // If second argument (value) is a function it's a converter...
  98. result = read(cookie, value);
  99. break;
  100. }
  101.  
  102. // Prevent storing a cookie that we couldn't decode.
  103. if (!key && (cookie = read(cookie)) !== undefined) {
  104. result[name] = cookie;
  105. }
  106. }
  107.  
  108. return result;
  109. };
  110.  
  111. config.defaults = {};
  112.  
  113. $.removeCookie = function (key, options) {
  114. if ($.cookie(key) === undefined) {
  115. return false;
  116. }
  117.  
  118. // Must not alter options, thus extending a fresh object...
  119. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  120. return !$.cookie(key);
  121. };
  122.  
  123. }));
  124. //COOKIE
  125.  
  126. var baseLink = "http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm";
  127. var privateMessageTitle = "Mettre ici le sujet du MP";
  128. var privateMessageContent = "Mettre ici le texte du MP ( utiliser \n pour revenir à la ligne)";
  129. var regexURLTopic = /http:\/\/www.jeuxvideo.com\/forums\/\d+-\d+-\d+-\d+-\d+-\d+-\d-[\w-]+.htm/;
  130. var regexPrivateMessage = /http:\/\/www.jeuxvideo.com\/messages-prives\/message.php\?id=\d+/;
  131. var privateMessageBaseLink = "http://www.jeuxvideo.com/messages-prives/nouveau.php?all_dest=";
  132.  
  133. var alreadySentNicknames;
  134. var privateMessageReceivers;
  135.  
  136. if($.cookie("privateMessageReceivers") == undefined) {
  137. $.cookie("privateMessageReceivers", "");
  138. }
  139.  
  140. if($.cookie("alreadySentNicknames") == undefined) {
  141. $.cookie("alreadySentNicknames", "");
  142. }
  143.  
  144. (function() {
  145. 'use strict';
  146.  
  147. function random(min, max) {
  148. return Math.floor(Math.random() * (max - min) ) + min;
  149. }
  150.  
  151. function getPrivateMessageLink() {
  152. var resultLink = privateMessageBaseLink;
  153. var privateMessageReceivers = $.cookie("privateMessageReceivers").split(";");
  154.  
  155. for(var i = 0; i < privateMessageReceivers.length; i++) {
  156. resultLink += privateMessageReceivers[i] + ';'
  157. }
  158. console.log(resultLink);
  159. return resultLink;
  160. }
  161.  
  162. function getNicknames() {
  163. var ourNickname = document.getElementsByClassName("account-pseudo")[0].innerText;
  164. var getNicknames = document.getElementsByClassName("xXx bloc-pseudo-msg text-user");
  165.  
  166. for(var i = 0; i < getNicknames.length; i++) {
  167. var presentNickname = getNicknames[i].innerText;
  168. privateMessageReceivers = $.cookie("privateMessageReceivers").split(";");
  169. alreadySentNicknames = $.cookie("alreadySentNicknames").split(";");
  170. if(ourNickname !== presentNickname && privateMessageReceivers.length < 35) {
  171. if(!privateMessageReceivers.includes(presentNickname) && !alreadySentNicknames.includes(presentNickname)) {
  172. if(privateMessageReceivers.length == 0) {
  173. $.cookie("privateMessageReceivers", $.cookie("privateMessageReceivers") + presentNickname);
  174. $.cookie("alreadySentNicknames", $.cookie("alreadySentNicknames") + presentNickname);
  175. } else {
  176. $.cookie("privateMessageReceivers", $.cookie("privateMessageReceivers") + ";" + presentNickname);
  177. $.cookie("alreadySentNicknames", $.cookie("alreadySentNicknames") + ";" + presentNickname);
  178. }
  179. }
  180. }
  181. }
  182. }
  183.  
  184. function getRandomTopic() {
  185. var actualURL = window.location.href;
  186. if (actualURL === "http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm") {
  187. var selectedTopic = document.getElementsByClassName("lien-jv topic-title")[random(4, 25)];
  188. selectedTopic.click();
  189. } else if(actualURL.match(regexURLTopic)) {
  190. getNicknames();
  191. privateMessageReceivers = $.cookie("privateMessageReceivers").split(";");
  192. console.log(privateMessageReceivers.length);
  193. if(privateMessageReceivers.length < 35) {
  194. location.replace(baseLink);
  195. } else {
  196. var privateMessagelink = getPrivateMessageLink();
  197. console.warn(privateMessagelink);
  198. $.removeCookie("privateMessageReceivers");
  199. location.replace(privateMessagelink);
  200. }
  201. } else if(actualURL.match(regexPrivateMessage)) {
  202. location.replace(baseLink);
  203. }
  204. else {
  205. document.getElementById("conv_titre").value = privateMessageTitle;
  206. document.getElementById("message").value = privateMessageContent;
  207. document.getElementsByClassName("btn btn-poster-msg js-post-message")[0].click();
  208. }
  209. }
  210.  
  211. setInterval(getRandomTopic(), 1000);
  212.  
  213. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement