// ==UserScript==
// @name Xchan Gold Alpha
// @version 0.0.0.9
// @description Experimental script to enhance xchan.pw
// @include https://xchan.pw/*
// @include http://xchan.pw/*
// @require https://cdn.jsdelivr.net/jquery.timeago/1.4.1/jquery.timeago.js
// @namespace https://greasyfork.org/users/2657
// ==/UserScript==
//ban notify
var bannotify = 0;
var rows;
if (bannotify == 1) {
var page;
if (localStorage.getItem("banpage")) {page = localStorage.getItem("banpage");}
setInterval(function () {
$.get("https://xchan.pw/?page=banlist", function (data) {
var lastb = $(data).find('a[href*="geo"]')[0];
if (lastb == page) {} else {alert('Novo Bam!'); page = lastb; localStorage.setItem("banpage", lastb)};
});
}, 100000);
$('input[name="reportpost"]').remove();
$.get("https://xchan.pw/manage_page.php?action=reports", function (data) {
$('.logo').after($(data).find('#contents'));
});
}
//yttitlestest
function extractVideoID(url){
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if ( match && match[7].length == 11 ){
return match[7];
}else{
return url;
}
}
$(document).on('click', ".mask", function() {
if ($(this).hasClass('isop')){$(this).prev().attr('height', '25x').attr('width', '300px');$(this).removeClass('isop');} else {
//$(this).prev().attr('height', '480x').attr('width', '600px');$(this).addClass('isop');
$(this).prev().clone().attr('height', '480x').attr('width', '600px').appendTo('.logo');
$('.logo').append('<div class="killvid">[Fechar]</div>');
jQuery('html,body').animate({scrollTop:0},0);
};
});
$(document).on('click', ".killvid", function() {
$(this).prev().remove();
$(this).remove();
});
$(document).on('mouseenter', 'a[href*="youtube.com/watch?"], a[href*="youtu.be"]', function() {
url = extractVideoID($(this).attr('href'));
$(this).replaceWith('<iframe class="ytv" src="https://www.youtube.com/v/'+url+'" width="300px" height="25px" ></iframe><div class="mask" style="display:inline-block;">OPEN </div>');
});
//ezspoiler
//function easyspoiler(){
// var text = $('#qr_message').val();
// var cont = text.match(/\*\*/g);
// var textf = text;
// if (cont.length%2 == 0) {
// console.log('even');
// for (i = 0; i < cont.length; i++) {
// if (i%2 == 0){
// textf = textf.replace('**','[spoiler]');
// }else{
// textf = textf.replace('**','[/spoiler]');
// }
// }
// }
// $('#qr_message').val(textf);
//};
//403 fixer
$('#quickform, #postform').find('input[accesskey="z"]').replaceWith('<input type="button" class="postfix" value="Enviar Fixed">');
function postfix(form){
$('<iframe />').attr('src', 'https://xchan.pw/b/').appendTo('body');
setTimeout(function(){document.forms[form].submit();}, 3000);
};
$(document).on('click', ".postfix", function() {
postfix($(this).closest('form').attr('name'));
easyspoiler();
});
//Hijacks
function semifag(){
$('.postername:contains("Semi")').parent().parent().css('background-image', 'url(\"http://a.pomf.se/rcqfit.png\")');
$('.postertrip:contains("hKvr")').parent().parent().css('background-image', 'url(\"http://a.pomf.se/ndnvht.png\")');
$('blockquote:contains("…"), blockquote:contains("daí"), blockquote:contains("Coë")' ).parent().css('background-image', 'url(\"http://a.pomf.se/aopqpg.jpg\")');
};
semifag();
//Hijacks//Location hack
location.replace("javascript:function expandimg(){};function expandthread(){};");
//Hijack ExpandImg
$(document).on('click', "a[href*='/src/']", function(e) {
e.preventDefault();
var src = $(this).attr('href');
var imgfl = $('<div><a href="javascript:;" onclick="$(this).remove(); return false;" ><img class="floatimg" src="'+src+'" style="max-width:1000px;"></div>');
if (src.indexOf(".webm") !=-1) {
imgfl = $('<div class="floatimg"><a href="javascript:;" onclick="$(\'.floatimg\').remove(); $(\'.floatvid\').pause(); return false;"><span style="cursor: pointer; cursor: hand;background:black;">[Fechar]</span></a><br><video width="auto" class="floatvid" height="auto" controls loop><source src="'+ $(this).attr('href') +'" type="video/webm">Your browser does not support the video tag.</video></div>');
}
$('#postform').prepend(imgfl);
jQuery('html,body').animate({scrollTop:0},0);
//$('.floatimg').draggable();
//javascript:expandimg('728609', 'https://xchan.pw/b/src/142252018357.jpg', 'https://xchan.pw/b/thumb/142252018357s.jpg', '344', '257', '175', '131');return false;
});
//webm improvement
/*$(document).on('click', "f[href*='webm']", function(e) {
e.preventDefault();
id = $(this).find('.thumb').attr('alt');
$(this).find('.thumb').css('display', 'none');
$(this).before('<div class="'+id+'vd" style="vertical-aligb:top;"><span class="clsvd" style="cursor: pointer; cursor: hand;" id="'+id+'">[Fechar]</span><br>< width="auto" height="auto" controls><source src="'+ $(this).attr('href') +'" type="video/webm">Your browser does not support the video tag.</video></div>');
});*/
$(document).on('click', ".clsvd", function() {
id = $(this).attr('id');
$('.thumb[alt*="'+id+'"]').css('display', 'block');
$('.'+id+'vd').remove();
});
//fix hidden threads
function hidefix(){
for (i = 0; i < hiddenthreads.length; i++) {
if (hiddenthreads.toString().indexOf(i)!==-1) {
$('#unhidethread'+hiddenthreads[i]+'').css('display', 'block');
$('#thread'+hiddenthreads[i]+'').css('display', 'none');
}
};
};
//Hijacks//Quick Reply Preview Image
$("[name='imagefile']:eq(1)").change(function () {
if (window.FileReader) {
var Reader = new FileReader();
var file = this.files[0];
window.file2 = file;
var previewarea = $('.qrpreviewer');
if (file.type.indexOf("video") > -1) {
previewarea.html('');
Reader.onload = function (event) {
previewarea.append([' <video width="100" height="88" controls><source src="'+ event.target.result +'" type="'+ window.file2.type +'">Your browser does not support the video tag.</video>'].join(''));
}
Reader.readAsDataURL(file);
} else {
previewarea.html('');
Reader.onload = function (event) {
previewarea.show().append(['<img style="max-height:88px;max-width:100px;" src="' + event.target.result + '" alt="">'].join(''));
}
Reader.readAsDataURL(file);
};
}
});
//anti-antispam
setTimeout(function(){
//location.reload();
}, 1500000);
//Hijacks//Quick Reply Replacer
$('#qr_form').draggable();
$(document).mousemove(function (e) {
window.pageX = e.pageX;
window.pageY = e.pageY;
});
function getSelectedText() {
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.selection) {
return document.selection.createRange().text;
}
return '';
};
$(document).on('click', ".qrp", function() {
tidrpt = $(this).attr('title');
tidrpts = tidrpt.split(' ');
var threadid = tidrpts[0];
var replyto = tidrpts[1];
var meval = "";
$('#qr_info').html("Reposta ao post: " + replyto + " na thread: " + threadid);
$('#qr_name').val($.cookie("name"));
$('#qr_postpassword').val($.cookie("postpassword"));
$('#qr_threadid').val(threadid);
//meval += $('#qr_message').val();
//leval = $('textarea[name="message"]').val();
//$('textarea[name="message"]').val('');
var text = getSelectedText();
if (text!='') {
text = text.split('\n');
var ftext = "";
text.forEach(function (str) {
if (str !== '') {
str = '>' + str + '\n';
} else {
str = '\n';
}
ftext += str;});
$('#qr_message').insertAtCaret('', ">>" + replyto + "\n" + ftext);
} else {
$('#qr_message').insertAtCaret('', ">>" + replyto + "\n");
};
//$("#qr_message")[0].value += '>>' + replyto + '\n';
//citeReply(replyto);
//$('#qr_message').val(meval + ">>" + replyto + "\n");
$('#qr_form').css({
'left' : window.pageX,
'top' : window.pageY,
'display' : 'block'
}).fadeIn('slow');
$('#qr_name').get(0).type = 'password';
$( '.namecheck' ).appendTo( '.qr_new' );
$('.postblock:contains("Mensagem"):eq(1)').append($('.movepreview'));
});
$(document).on('click', "img[alt='Close']", function() {
$( '.namecheck' ).appendTo( '.new' );
});
function prepqrp(){
$('a[title="Resposta Rápida"]').each(function() {
var onc = $(this).attr('onclick');
oncf = onc.replace('javascript:qr(','').replace(',', '').replace(');', '');
//oncfs = oncf.split(' ');
$(this).attr('onclick', '');
$(this).attr('title', oncf);
$(this).attr('class', 'qrp');
});
};
//Hijacks//Expand Thread
$(document).on('click', ".expandthread", function() {
var tid = $(this).parent().attr('onclick');
tids = tid.split("'");
var c = tids[1];
var d = tids[3];
$('.expandedthread').remove();
var e = $('<div></div>').addClass('expandedthread').attr('style', 'background:dimgray;position:fixed;top:3px;left:10%;width:600px;height:99%;border: solid 1px;overflow-y:scroll;overflow-x:hidden;')
if (e.length) {
e.prepend(_('Expanding thread') + '...<br /><br />');
e.load(ku_boardspath + '/expand.php?board=' + d + '&threadid=' + c, {}, function (a, b) {
if (!a) {
e.html(_("something went wrong (blank response)"))
}
if (b == "error") {
alert(_('Something went wrong...'))
}
e.prepend('<div class="closexp" style="cursor:pointer;cursor:hand;position:fixed;background:orange;">[Fechar]</div>');
$('body').append(e);
delandbanlinks(this);
loop();
})
}
return false
});
$(document).on('click', ".closexp", function() {
$('.expandedthread').remove();
});
/*$(document).on('click', ".expandthread", function() {
var tid = $(this).parent().attr('onclick');
tids = tid.split("'");
var c = tids[1];
var d = tids[3];
var e = $("#replies" + c + d);
if (e.length) {
e.prepend(_('Expanding thread') + '...<br /><br />');
e.load(ku_boardspath + '/expand.php?board=' + d + '&threadid=' + c, {}, function (a, b) {
if (!a) {
e.html(_("something went wrong (blank response)"))
}
if (b == "error") {
alert(_('Something went wrong...'))
}
delandbanlinks(this);
loop();
})
}
return false
});*/
//hideposts
function hideposts(){$('.extrabtns').prepend('<div class="hidepost" style="display:inline-block;"><img src="https://xchan.pw/css/icons/blank.gif" border="0" class="hidethread" alt="hide"></div>');};
if (localStorage.getItem("hidenposts")){var rawposts = localStorage.getItem("hidenposts"); var hidenposts = JSON.parse(rawposts);} else {var hidenposts = [];};
$(document).on('click', ".hidepost", function() {
id = $(this).parent().parent().attr('id');
id = '#' + id;
if ( hidenposts.indexOf(id) == -1) {hidenposts.push(id);
localStorage.setItem("hidenposts", JSON.stringify(hidenposts))
$(this).parent().parent().attr('style', 'height:17px;overflow:hidden;');
} else {
hidenposts.splice(hidenposts.indexOf(id), 1);
localStorage.setItem("hidenposts", JSON.stringify(hidenposts))
$(this).parent().parent().attr('style', 'height:auto;overflow:;');
};
});
$("<style>").text(""+hidenposts+"{height:17px;overflow:hidden;}").appendTo("head");
//Hijacks//Hover
$("<style>").text(".reflinkpreview {display:none!important;} div[class^='floater'], .hold {min-width: 0; z-index: 9999; margin: 0 !important; display: block !important; max-width: 808.5px; background:grey; font-family: 'Trebuchet MS','Tahoma','Verdana','Arial',sans-serif; font-size: 13px; text-align: left;}").appendTo("head");
$('.logo').append('<div class="previews"></div>');
var waiter;
var c;
$(document).on('mouseenter', 'a[class^="ref|"]', function() {
c = $(this).attr("class").split('|');
var htop = $(this).offset().top;
var hleft = $(this).offset().left;
waiter = window.setTimeout(function() {
$('.floater').attr('class', 'hold');
var d = $("<div></div>").addClass('floater').attr({
style : "position:absolute;width:400px;"
});
if ($('#postform [name=board]').val() == c[1] && $('#reply' + c[3]).length && (($('#thumb' + c[3]).length && $('#thumb' + c[3] + " img:first-child").attr("src").lastIndexOf("thumb") != -1) || !$('#thumb' + c[3]).length)) {
var f = true;
d.html($("#reply" + c[3]).parents("table").html())
} else {
d.html('Carregando...').toggle("normal");
$.get(ku_boardspath + '/read.php?b=' + c[1] + '&t=' + c[2] + '&p=' + c[3] + '&single', {}, function (a, b) {
if (b != "success") {
alert('wut')
} else {
if (a) {
d.html(a)
} else {
d.html(_("something went wrong (blank response)"))
}
}
})
}
$('.previews').append(d).slideDown( "slow" );
//loop();
if (f) {
//d.toggle("normal")
};
$('.floater')
.css("top", htop)
.css("left",(hleft-100))
}, 500);
});
$(document).on('mouseleave', 'a[class^="ref|"]', function() { clearTimeout(waiter); });
$(document).on('mouseleave', '.previews', function() {
$('.floater').remove();
$('.hold').remove();
});
//Start
$( document ).ready(function() {
loop();
(function() {
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = 'http://www.stackoverflow.com/favicon.ico';
document.getElementsByTagName('head')[0].appendChild(link);
}());
//$('#favicon').remove();
//$("#favicon").attr("href","http://i.imgur.com/AB4G76Z.png");
//$('link[rel="shortcut icon"]').remove();
//$('head').append('<link href="https://i.imgur.com/AB4G76Z.png" id="favicon" rel="shortcut icon">');
//addpreviewevents2();
$('#qr_form').find('.postblock:contains("Mensagem")').append('<div class="qrpreviewer"></div>');
$('.qrpreviewer').attr('style', 'background:none; border:0px; width:100px; padding:0px; position:relative; ');
});
window.dt = "";
//text-format
jQuery.fn.extend({
insertAtCaret: function(myValue, myValueE){
return this.each(function(i) {
if (document.selection) {
//For browsers like Internet Explorer
this.focus();
sel = document.selection.createRange();
sel.text = myValue + myValueE;
this.focus();
}
else if (this.selectionStart || this.selectionStart == '0') {
//For browsers like Firefox and Webkit based
var startPos = this.selectionStart;
var endPos = this.selectionEnd;
var scrollTop = this.scrollTop;
this.value = this.value.substring(0, startPos)+myValue+this.value.substring(startPos,endPos)+myValueE+this.value.substring(endPos,this.value.length);
this.focus();
this.selectionStart = startPos + myValue.length;
this.selectionEnd = ((startPos + myValue.length) + this.value.substring(startPos,endPos).length);
this.scrollTop = scrollTop;
} else {
this.value += myValue;
this.focus();
}
})
}
});
$('textarea[id="qr_message"]').after('<br class="stylebar">');
$('.stylebar').after('<input class="formbutton_SS" type="button" value="Spoiler" /><input class="formbutton_B" type="button" value="B" /><input class="formbutton_R" type="button" value=">" /><input class="formbutton_S" type="button" value="S" /><input class="formbutton_I" type="button" value="I" /><input class="formbutton_C" type="button" value="Code" />');
$('.formbutton_I').css('font-style', 'italic');
$('.formbutton_S').css('text-decoration', 'line-through');
$('.formbutton_R').css('color', 'green');
$('.formbutton_B').css('font-weight', 'bold');
$('.formbutton_SS').css('font-weight', 'bold');
$('.formbutton_C').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret("[code]", "[/code]");
});
$('.formbutton_I').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret("[i]", "[/i]");
});
$('.formbutton_S').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret("[s]", "[/s]");
});
$('.formbutton_R').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret(">", "");
});
$('.formbutton_B').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret("[b]", "[/b]");
});
$('.formbutton_SS').on('click', function(){
$('textarea[id="qr_message"]').insertAtCaret("[spoiler]", "[/spoiler]");
});
//Zoom Thumbs
/*$('.thumb').each( function () {
var w = $(this).attr('width');
var h = $(this).attr('height');
$(this).attr({
width: (parseInt(w) + 40),
height: (parseInt(h) + 40)
});
} );*/
//Menu
$(".navbar").after("<div class='optionslink hov' style='display:inline;cursor: pointer; cursor: hand; width:auto;'><b>[Opções de Script]</b></div>")
$(".navbar").after("<div class='optionsmenu' style='display:none;background:rgb(199, 199, 199);font-weight:bold;padding:3px;cursor: pointer; cursor: hand;'></div>")
$('.optionsmenu').append(' <span class="capture hov">[Capturar Pagina]</span> <span class="Dcatalog hov">[Catalogo]</span>');
$('.optionsmenu').append(' <span class="hidetrips hov">[Esconder Trips]</span>');
$('.optionsmenu').append(' <span class="hidetripposts hov">[Esconder Trip Posts]</span>');
$('.optionsmenu').append(' <span class="hideanon hov">[Esconder Anônimos]</span>');
$(document).on('mouseenter', ".hov", function() {
$(this).css('background', 'orange');
}).on('mouseleave', ".hov", function() {
$(this).css('background', 'rgb(199, 199, 199)');
});
//trip hidder
$("<style>").text(".shidden{display:none;}").appendTo("head");
function showtrips(){
localStorage.removeItem("hidetrips");
$('.showtrips').text('[Esconder Trips]');
$('.showtrips').attr('class', 'hidetrips');
$('.shidden').removeClass('shidden');
};
function hidetrips(){
localStorage.setItem("hidetrips", "OFF")
$('.hidetrips').text('[Mostrar Trips]');
$('.hidetrips').attr('class', 'showtrips');
$('.postertrip, .postername').addClass('shidden');
};
$(document).on('click', ".showtrips", function() { showtrips(); });
$(document).on('click', ".hidetrips", function() { hidetrips(); });
if (localStorage.getItem("hidetrips")){ hidetrips(); };
//-
//trip post hidder
function showtrippost(){
localStorage.removeItem("hidetripposts");
$('.showtripposts').text('[Esconder Trip Posts]');
$('.showtripposts').attr('class', 'hidetripposts');
$('.shidden').removeClass('shidden');
};
function hidetrippost(){
localStorage.setItem("hidetripposts", "OFF")
$('.hidetripposts').text('[Mostrar Trip Posts]');
$('.hidetripposts').attr('class', 'showtripposts');
$('.postername:not(:contains("Anônimo"))').parent().parent().addClass('shidden');
};
$(document).on('click', ".showtripposts", function() { showtrippost(); });
$(document).on('click', ".hidetripposts", function() { hidetrippost(); });
if (localStorage.getItem("hidetripposts")){ hidetrippost(); };
//Anon post hidder
function showanon(){
localStorage.removeItem("hideanon");
$('.showanon').text('[Esconder Anônimos]');
$('.showanon').attr('class', 'hideanon');
$('.shidden').removeClass('shidden');
};
function hideanon(){
localStorage.setItem("hideanon", "OFF")
$('.hideanon').text('[Mostrar Anônimos]');
$('.hideanon').attr('class', 'showanon');
$('.postername:contains("Anônimo")').parent().parent().addClass('shidden');
};
$(document).on('click', ".showanon", function() { showanon(); });
$(document).on('click', ".hideanon", function() { hideanon(); });
if (localStorage.getItem("hideanon")){ hideanon(); };
//
$(document).on('click', ".optionslink", function() {
$(".optionsmenu").css("display","block");
$('.optionslink').html("<b><font color='red'>[Fechar]</font></b>");
$('.optionslink').attr('class', 'optionslinkclose hov');
});
$(document).on('click', ".optionslinkclose", function() {
$(".optionsmenu").css("display","none");
$('.optionslinkclose').html("<b>[Opções de Script]</b>");
$('.optionslinkclose').attr('class', 'optionslink hov');
});
$(document).on('click', ".menubut", function() {
$('.menu').attr('display', 'block');
});
//Image Merger
$(document).on('click', ".merger", function() {
$('body').prepend('<br><div style="display:inline-block;border:1px solid;width:auto;height:auto;" class="workspace"><center></div>');
$('.workspace').before('<input class="maintCostField" type="file"/> Width:<input class="width" type="text"/> Height:<input class="height" type="text"/> <button class="savemerge" type="button">Salvar</button>');
});
$(document).on('click', ".savemerge", function() {
target = $('.workarea')
html2canvas(target, {
onrendered: function(canvas) {
Canvas2Image.saveAsJPEG(canvas)
}
});
});
$(document).on('change', '.maintCostField', function(){
if (window.FileReader) {
var Reader = new FileReader();
var file = this.files[0];
var previewarea = $('.workspace');
Reader.onload = function (event) {
previewarea.append(['<img class="dra" style="max-width:100%;max-height:100%;" src="' + event.target.result + '" alt="">'].join(''));
}
Reader.readAsDataURL(file);
}
});
$(document).on('click', '.dra', function(){
$(this).draggable();
});
$(document).on('change', '.width', function(){
wid = $(this).val() + "px";
$('.workspace').css('width', wid);
});
$(document).on('change', '.height', function(){
wid = $(this).val() + "px";
$('.workspace').css('height', wid);
});
//Debug
$(document).on('click', ".capture", function() {
html2canvas(document.body, {
onrendered: function(canvas) {
Canvas2Image.saveAsJPEG(canvas)
}
});
});
// Catalog
$("<style>").text(".catalogimg > img {max-width:100%;max-height:100%;} .catalogitem {margin-bottom:10px;}").appendTo("head");
$(document).on('click', ".Dcatalog", function() {
$('.catalog').remove();
$('body').prepend('<div class="catalog" style="background: dimgray;border: solid 1px;overflow-y:scroll;overflow-x:hidden;width:240px;height:650px;position:fixed;top:100px;left:10px;"><table id="catalogt"><tbody><div class="closecat hov" style="font-size: 15px;font-weight: bold;position:fixed;top:80px;left:10px;color:red;font-size:11px;cursor: pointer; cursor: hand;">[Fechar Catalogo]</div></tbody></table></div>');
$.get("https://xchan.pw/b/catalog.html", function (data) {
$(data).find('a[class^="ref|"]').each(function () {
var href = $(this).attr('href');
var c = $(this).attr("class").split('|');
var d = $("<span></span>").addClass('catalogimg').attr({
style : "max-width:220px;background:#F7F7F7;"
});
var g = $("<div></div>").addClass('catalogtext').attr({
style : "overflow-x:hidden;overflow-y:scroll;max-height:200px;max-width:220px;background:#F7F7F7;"
});
$.get(ku_boardspath + '/read.php?b=' + c[1] + '&t=' + c[2] + '&p=' + c[3] + '&single', {}, function (a, b) {
if (b != "success") {
alert('wut')
} else {
if (a) {
var z = $('<img />').html(a).find('.thumb').removeClass();
var y = $('<blockquote>').html(a).find('blockquote');
d.html(z);
g.html(y);
} else {
d.html(_("something went wrong (blank response)"))
}
}
})
var wrap = $("<div></div>").addClass('catalogitem').append(d).wrapInner('<a href='+ href +'>').append(g);
$('#catalogt').append(wrap);
});
});
});
$(document).on('click', ".closecat", function() {
$('.catalog').remove();
});
//Relative Time
function reltime() {
$('.time').remove();
$( "label:contains('@')" ).each(function() {
var vovar = $(this).contents().map(function() {
if( this.nodeType === 3 ) {
return this.data;
}
}).get().join('');
vovar1 = vovar.split("@");
vovardate = vovar1[0].split("/");
vovaryear = vovardate[2].split(" ");
vovarmonth = vovardate[1] - 1;
vovartime = vovar1[1].split(":");
tiem = new Date(vovaryear[0], vovarmonth, vovardate[0], vovartime[0], vovartime[1])
tiemiso = tiem.toISOString();
tiemago = jQuery.timeago(tiemiso);
$( this ).append( '<span class="time">( <bold>' + tiemago + ' </bold>)</span>' );
});
};
//Name Box Fixes
$('input[name="name"]').get(0).type = 'password';
$( 'input[name="name"]' ).focus(function() {
$('input[name="name"]').get(0).type = 'text';
$('#qr_name').get(0).type = 'text';
});
$( 'input[name="name"]' ).focusout(function() {
$('input[name="name"]').get(0).type = 'password';
$('#qr_name').get(0).type = 'password';
});
$( 'input[name="name"]:first' ).wrap( '<span class="new"></span>' );
$( '#qr_name' ).wrap( '<span class="qr_new"></span>' );
$( '.new' ).append( '<input type="checkbox" class="namecheck" value="Bike" checked="checked">' );
if (localStorage.getItem("namecheck") === null) {}else{$( ".namecheck" ).prop( "checked", false ); $( 'input[name="name"], #qr_name' ).prop('disabled',true);};
$(document).on('change', ".namecheck", function() {
if ( $( '.namecheck' ).prop( "checked" ) ) {$( 'input[name="name"], #qr_name' ).prop('disabled',false); localStorage.removeItem('namecheck');}else{$( 'input[name="name"], #qr_name' ).prop('disabled',true); localStorage.setItem('namecheck', '');};
});
//Backlinks
function backlinks() {
$('#delform').find(".reply").not('.protect').each(function() {
blink($(this));
});
$('.floater, .hold').find(".reply").not('.protect').each(function() {
blink($(this));
});
};
function blink(t){
t.addClass('protect');
rid = t.attr('id').replace('reply','');
datas = t.find('.reflink').find("a:nth-child(2)").attr('href');
t.find("a[class^='ref|']").each(function() {
var quoted = $(this).text();
quoteds = quoted.replace('>>','');
//console.log(datas + "|" + rid + "+" + quoteds + ")");
backquote(quoteds, rid, datas);
});
};
function backquote(quoteds, rid, datas){
splicer = datas.replace('.html#i','/');
splicer2 = splicer.split('/');
$(".reflink:contains('" +quoteds+ "')").after('<a href="/'+splicer2[1]+'/res/'+splicer2[3]+'.html#'+rid+'" onclick="return highlight(\''+rid+'\', true);" class="ref|'+splicer2[1]+'|'+splicer2[3]+'|'+rid+'">>>'+rid+'</a>');
};
/*function backlinks() {
$('#delform').find(".reply").not('.protect').each(function() {
$(this).addClass('protect');
rid = this.id.replace('reply','');
datas = $(this).find('.reflink').find("a:nth-child(2)").attr('href');
$(this).find("a[class^='ref|']").each(function() {
var quoted = $(this).text();
quoteds = quoted.replace('>>','');
console.log(datas + "|" + rid + "+" + quoteds + ")");
backquote(quoteds, rid, datas);
});
});
};
function backquote(quoteds, rid, datas){
splicer = datas.replace('.html#i','/');
splicer2 = splicer.split('/');
$(".reflink:contains('" +quoteds+ "')").after('<a href="/'+splicer2[1]+'/res/'+splicer2[3]+'.html#'+rid+'" onclick="return highlight(\''+rid+'\', true);" class="ref|'+splicer2[1]+'|'+splicer2[3]+'|'+rid+'">>>'+rid+'</a>');
};*/
//live index
var highest = -Infinity;
var compareme = 99999999999999999;
window.updateid = "";
function initupdate(){
var highest = -Infinity;
$('#delform').find("input[name='post[]']").each(function() {
splice = $(this).attr('value');
numb = parseInt(splice)
highest = Math.max(highest, parseFloat(numb));
});
return highest;
};
initupdate();
function update(){
var compareme = 0;
$.get("" + document.location, function (data) {
$(data).find("input[name='post[]']").each(function() {
splice = $(this).attr('value');
numb = parseInt(splice)
compareme = Math.max(compareme, parseFloat(numb));
window.updateid = compareme;
});
});
};
setInterval(function () {
update();
if (window.updateid > initupdate()){
$.get("" + document.location, function (data) {
$("#delform").replaceWith($(data).filter("#delform"));
}).done(function() {
loop();
notify();
hidefix();
});
};
reltime();
}, 10000);
function nofegget(){
$('blockquote').each(function() {$(this).html($(this).html().split('____')[0])});
};
//nofegget();
//Loop
function loop(){
$('blockquote').find('a[href*="youtube.com/watch?"], a[href*="youtu.be"]').not( ".titled" ).each(function() {
//yttitle(this);
});
$('blockquote').find('a').not( 'a[class^="ref|"]' ).each(function() {
$(this).attr('target','_blank');
});
reltime();
backlinks();
prepqrp();
if (localStorage.getItem("hidetripposts")){ hidetrippost(); };
if (localStorage.getItem("hidetrips")){ hidetrips(); };
if (localStorage.getItem("hideanon")){ hideanon(); };
semifag();
hideposts();
//nofegget();
};
//Notification
var title = $(document).prop('title');
function notify(){
var state = document["visibilityState"];
if (state == "hidden")
{
$('#favicon').remove();
$('link[rel="shortcut icon"]').remove();
$('head').append('<link href="https://i.imgur.com/TirPmur.png" id="favicon" rel="shortcut icon">');
$(document).prop('title', 'New Posts! '+ title +'');
} else if (state == "visible") {
$('#favicon').remove();
$('link[rel="shortcut icon"]').remove();
$('head').append('<link href="https://i.imgur.com/TirPmur.png" id="favicon" rel="shortcut icon">');
$(document).prop('title', 'New Posts! '+ title +'');
setTimeout(function(){
$('#favicon').remove();
$('head').append('<link href="https://i.imgur.com/AB4G76Z.png" id="favicon" rel="shortcut icon">');
$(document).prop('title', title );
},5000)
}
};
var onVisibilityChange = function (args) {
var state = document["visibilityState"];
if (state == "visible")
{
$('#favicon').remove();
$('head').append('<link href="https://i.imgur.com/AB4G76Z.png" id="favicon" rel="shortcut icon">');
$(document).prop('title', title );
}
};
document.addEventListener("visibilitychange", onVisibilityChange, false);