Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name tgchan autoupdate
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description tgchan autoupdate
- // @author Rex
- // @include http*://tgchan.org/kusaba/quest/res/*
- // @include http*://tgchan.org/kusaba/questarch/res/*
- // @grant none
- // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
- // @run-at document-start
- // ==/UserScript==
- jQuery.noConflict();
- jQuery(document).ready(function($) {
- function checkWTForUpdates(timeout) {
- var urlparts = window.location.href.split('/');
- new Ajax.Request(ku_boardspath + '/threadwatch.php?board=' + urlparts[4] + '&threadid=' + /*urlparts.pop().split('.')[0]*/'0',
- {
- method:'get',
- onSuccess: function(transport){
- var response = transport.responseText;
- if(!response)
- location.reload();
- var resObject = jQuery('<div>').append(transport.responseText).find('strong');
- if(resObject.html() != '0') {
- jQuery.get(window.location.href, function( data ) {
- var n = data.indexOf('<div style="display: none;" class="unicorn">');
- var d = data.substring(n);
- d = d.substring(0, d.indexOf('</form>'));
- var pagedata = jQuery('<div>').append(d);
- jQuery('table:has(.reply)').last().after(pagedata.find('table:has(.reply)').toArray().filter(function(x) { return jQuery('#' + jQuery(x).find('.reply').get(0).id).length == 0; }));
- window.location.replace(resObject.parent().attr('href'));
- setTimeout(function() {
- checkWTForUpdates(5000);
- }, 5000);
- });
- }
- else {
- var newTimeout = timeout >= 30000 ? timeout : timeout + 5000;
- setTimeout(function() {
- checkWTForUpdates(newTimeout);
- }, timeout);
- }
- },
- onFailure: function(){ location.reload(); }
- });
- }
- setTimeout(function() {
- checkWTForUpdates(5000);
- }, 5000);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement