Guest User

Untitled

a guest
Mar 13th, 2018
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         tgchan autoupdate
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  tgchan autoupdate
  6. // @author       Rex
  7. // @include      http*://tgchan.org/kusaba/quest/res/*
  8. // @include      http*://tgchan.org/kusaba/questarch/res/*
  9. // @grant        none
  10. // @require      https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  11. // @run-at       document-start
  12. // ==/UserScript==
  13. jQuery.noConflict();
  14.  
  15. jQuery(document).ready(function($) {
  16.     function checkWTForUpdates(timeout) {
  17.         var urlparts = window.location.href.split('/');
  18.         new Ajax.Request(ku_boardspath + '/threadwatch.php?board=' + urlparts[4] + '&threadid=' + /*urlparts.pop().split('.')[0]*/'0',
  19.         {
  20.             method:'get',
  21.             onSuccess: function(transport){
  22.                 var response = transport.responseText;
  23.                 if(!response)
  24.                     location.reload();
  25.                 console.log(transport.responseText);
  26.                 var resObject = jQuery('<div>').append(transport.responseText).find('strong');
  27.                 if(resObject.html() != '0') {
  28.                     window.location.replace(resObject.parent().attr('href'));
  29.                     location.reload();
  30.                 }
  31.                 else {
  32.                     var newTimeout = timeout >= 30000 ? timeout : timeout + 5000;
  33.                     setTimeout(function() {
  34.                         checkWTForUpdates(newTimeout);
  35.                     }, timeout);
  36.                 }
  37.             },
  38.             onFailure: function(){ location.reload(); }
  39.         });
  40.     }
  41.     //window.scrollTo(0,document.body.scrollHeight);
  42.     setTimeout(function() {
  43.         checkWTForUpdates(5000);
  44.     }, 5000);
  45. });
Advertisement
Add Comment
Please, Sign In to add comment