Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name codeFarm
- // @namespace wtBlock
- // @include http://worldoftanks.ru/*
- // @include http://worldofwarplanes.ru/*
- // @version 2
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- var your_url='http://pastebin.com/dhKt1ztV';//сюда вписываем адрес pastebin с использованными кодами
- jQuery.ajax = (function(_ajax){
- var protocol = location.protocol,
- hostname = location.hostname,
- exRegex = RegExp(protocol + '//' + hostname),
- YQL = 'http' + (/^https/.test(protocol)?'s':'') + '://query.yahooapis.com/v1/public/yql?callback=?',
- query = 'select * from html where url="{URL}" and xpath="*"';
- function isExternal(url) {
- return !exRegex.test(url) && /:\/\//.test(url);
- }
- return function(o) {
- var url = o.url;
- if ( /get/i.test(o.type) && !/json/i.test(o.dataType) && isExternal(url) ) {
- // Manipulate options so that JSONP-x request is made to YQL
- o.url = YQL;
- o.dataType = 'json';
- o.data = {
- q: query.replace(
- '{URL}',
- url + (o.data ?
- (/\?/.test(url) ? '&' : '?') + jQuery.param(o.data)
- : '')
- ),
- format: 'xml'
- };
- // Since it's a JSONP request
- // complete === success
- if (!o.success && o.complete) {
- o.success = o.complete;
- delete o.complete;
- }
- o.success = (function(_success){
- return function(data) {
- if (_success) {
- // Fake XHR callback.
- _success.call(this, {
- responseText: data.results[0]
- // YQL screws with <script>s
- // Get rid of them
- .replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, '')
- }, 'success');
- }
- };
- })(o.success);
- }
- return _ajax.apply(this, arguments);
- };
- })(jQuery.ajax);
- function waitForJquery(){
- if (typeof unsafeWindow.jQuery == 'undefined') {
- window.setTimeout(waitForJquery, 100);
- } else {
- $ = unsafeWindow.jQuery;
- //your code here
- }
- }
- waitForJquery();
- var count=0,
- format='',
- runTimes=0,
- codes={},
- letters=['F', 'G','C','R','T','Y', 'U', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M']
- ;
- $('body').bind('code:generate', function(e){
- if(format=='')
- format=$('#id_code').val();
- var
- regLet=new RegExp("n{1}"),
- regDig=new RegExp("x{1}")
- ;
- testcode=format;
- var tempcodes={}, tmp='';
- while(regLet.test(testcode)){
- tmp=letters[Math.floor(Math.random()*(letters.length))];
- if(tempcodes[tmp]!=true){
- tempcodes[tmp]=true;
- testcode=testcode.replace(regLet, tmp);
- }
- }
- var tempcodes={}, tmp='';
- while(regDig.test(testcode)){
- tmp=(2+Math.floor(Math.random()*8)).toString();
- if(tempcodes[tmp]!=true){
- tempcodes[tmp]=true;
- testcode=testcode.replace(regDig, tmp);
- }
- }
- if(typeof(codes[testcode])=='undefind'||codes[testcode]!=true){
- codes[testcode]==true;
- $('#id_code').val(testcode);
- $('body').append(testcode+'<br>');
- //$('body').prepend(testcode+' ');//нахуй переносы
- }
- });
- $('body').bind('code:send', function(e){
- $("#button-submit").click();
- $("#js-edit-bonuscode-form").submit();
- });
- $('body').bind('code:clear', function(e){
- $('#id_code').val('');
- });
- $('body').bind('code:wait10min', function(e){
- //$('body').prepend('waiting 10 min<br>'); //нахуй
- //сообщение о паузе
- $('#ui-dialog-title-js-edit-bonuscode-form-dialog').text('Проверено '+count+'. Пауза 10 минут.');
- setTimeout(function(){
- $('body').trigger('code:gen5codes');
- }, (10*1000*60+2000));
- $('#id_code').val('');
- });
- $('body').bind('code:gen5codes', function(){
- if(runTimes>4){
- $('body').trigger('code:wait10min');
- runTimes=0;
- return true;
- }else
- runTimes++;
- $('#ui-dialog-title-js-edit-bonuscode-form-dialog').text('Проверено '+count+'. Попытка '+runTimes+' из 5');//инфа о попытках
- $('body').trigger('code:generate');
- if ($('body').html().split($('#id_code').val()).length - 1 >1) {$('body').trigger('code:generate');};
- $('body').trigger('code:send');
- count++;//счетчик проверенных
- setTimeout(function(){
- $('body').trigger('code:clear');
- $('body').trigger('code:gen5codes');
- }, 3400);
- });
- $('body').dblclick(function(){
- var used_codes = '';
- if (your_url.length>0){
- $.ajax({url: your_url,type: 'GET',success: function(res) {var text = res.responseText;used_codes = text;
- used_codes = used_codes.substring(used_codes.indexOf('catchTab(this,event)">')+22, used_codes.indexOf('</textarea>'));
- var arr = used_codes.split('\n');
- arr.forEach(function(str) {
- $('body').append(str+'<br>');
- });
- $('body').trigger('code:gen5codes');
- }});
- } else {$('body').trigger('code:gen5codes');};
- //$('body').trigger('code:gen5codes');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement