Advertisement
Guest User

Comfy shitposter

a guest
Jul 29th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Комфортный срун
  3. // @author      1chanpatriot
  4. // @description Позволяет комфортно срать на колчке
  5. // @namespace   1chan
  6. // @include     https://1chan.ca/weedcaptcha/index.php
  7. // @include     https://1chan.ca/news/res/*
  8. // @version     0.1
  9. // @grant       none
  10. // ==/UserScript==
  11.  
  12. var captchas = {
  13.     "бульбулятор": 11038,
  14.     "heart": 1519,
  15.     "musical note": 1413,
  16.     "Шинку": 17966,
  17.     "Собак": 1462,
  18.     "Майли Сайрус": 22302,
  19.     "Арбуз": 10601,
  20.     "Розетка": 9766,
  21.     "bug": 2397,
  22.     "шизик": 4033,
  23.     "Паук": 11333,
  24.     "жопа слона": 5712,
  25.     "Король Ночи": 11534,
  26.     "house": 2010,
  27.     "Хуйло": 14489,
  28.     "Синий кит": 10068,
  29.     "Попка": 6376,
  30.     "Лимон": 9898,
  31.     "Мизулина": 13174,
  32.     "стульчак": 21956,
  33.     "Александр Шульгин": 11236,
  34.     "light bulb": 1937,
  35.     "flag": 2398,
  36.     "clock": 2880,
  37.     "яжка": 22933,
  38.     "Пацифик": 12576,
  39.     "pen": 1793,
  40.     "Спиннер": 11447,
  41.     "Стивен Хокинг": 10927,
  42.     "спайсы": 20792,
  43.     "Украина": 20385,
  44.     "Альберт Хоффман": 14433,
  45.     "Суисейсеки": 12382,
  46.     "шприц": 18682,
  47.     "Всевидящее око": 14144,
  48.     "КЛЛ": 13587,
  49.     "Соусейсеки": 19633,
  50.     "трава": 918,
  51.     "анонимус": 3268,
  52.     "world": 3040
  53. };
  54.  
  55. function getImageSize(url, callback) {
  56.   var xhr = new XMLHttpRequest();
  57.   xhr.onload = function() {
  58.     callback(xhr.response.size);
  59.   };
  60.   xhr.open('GET', url);
  61.   xhr.responseType = 'blob';
  62.   xhr.send();
  63. }
  64.  
  65. function solveCaptcha(){
  66.     var captchaText = document.getElementsByClassName('captchaText')[0].innerText;
  67.     [].forEach.call(document.getElementsByClassName('captchaImage'), function(v,i,a) {
  68.       getImageSize(v.src, function(size) {
  69.             if (size == captchas[captchaText]){
  70.                 v.click();
  71.                 window.parent.postMessage("addComment","*");
  72.             }
  73.         });
  74.     });
  75. }
  76.  
  77. function addComment(){
  78.     var xhr = new XMLHttpRequest();
  79.     var body = 'post_id=' + encodeURIComponent(document.getElementsByName('post_id')[0].value) +
  80.         '&text=' + encodeURIComponent(document.getElementsByName('text')[0].value) +
  81.         '&homeboard=' + encodeURIComponent(document.getElementsByName('homeboard')[0].value);
  82.     var commentForm = document.getElementById('comment_form');
  83.     xhr.open("POST", commentForm.action, true);
  84.     xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  85.     xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  86.     xhr.setRequestHeader('Accept', 'application/json');
  87.     xhr.onreadystatechange = function(){
  88.         if (xhr.readyState == 4) {
  89.             var result = JSON.parse(xhr.responseText);
  90.             if (result.isValid === true){
  91.                 document.getElementById('comment_form_text').value = '';
  92.                 var iframe =  document.getElementsByTagName("IFRAME")[0];
  93.                 iframe.src = iframe.src;
  94.             }
  95.         }
  96.     };
  97.     xhr.send(body);
  98. }
  99.  
  100. $(document).ready(function() {
  101.     if (window.top === window.self) {
  102.         var iframe =  document.getElementsByTagName("IFRAME")[0];
  103.         document.getElementById('comment_form_text').addEventListener("keydown", function(e) {
  104.             if (e.ctrlKey && e.keyCode === 13) {
  105.                 iframe.contentWindow.postMessage('solveCaptcha', '*');
  106.             }
  107.         });
  108.         var commentForm = document.getElementById('comment_form');
  109.         var submitButton = commentForm.getElementsByTagName('input')[5];
  110.         submitButton.addEventListener("click", function(e) {
  111.             iframe.contentWindow.postMessage('solveCaptcha', '*');
  112.         });
  113.         window.onmessage = function(e){
  114.             if (e.data == 'addComment') {
  115.                 addComment();
  116.             }
  117.         };
  118.     }
  119.     else {
  120.         window.onmessage = function(e){
  121.             if (e.data == 'solveCaptcha') {
  122.                 solveCaptcha();
  123.             }
  124.         };
  125.     }
  126. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement