Skip to content

Instantly share code, notes, and snippets.

@theCrius
Last active June 3, 2018 14:25
Show Gist options
  • Save theCrius/04dc86bea0ed0f1cbec7e57f1aaff9aa to your computer and use it in GitHub Desktop.
Save theCrius/04dc86bea0ed0f1cbec7e57f1aaff9aa to your computer and use it in GitHub Desktop.
ViolentMonkey Script to add QoL feature on ~tilde.net alpha
// ==UserScript==
// @name Tildes Aplha Extended
// @namespace https://tildes.net/
// @version 0.1
// @description Simple QoL improvements while they are developed in the source code
// @author Tildes Users
// @match https://tildes.net/*
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @grant GM_addStyle
// ==/UserScript==
//Tampermonkey has issue with GM_addStyle, please use this with ViolentMonkey: https://violentmonkey.github.io/get-it/
//Tags for comments hidden by default, visible on mouseover - by tesseractcat
GM_addStyle(`
.fixed-bottom-right {
position: fixed;
bottom: 5vh;
right: 5vw;
}
.comment-tags li {
display:none;
}
.comment-tags::after {
content:"Tags hidden";
font-size:10px;
display:inline;
}
.comment-tags:hover::after {
display:none;
}
.comment-tags:hover li {
display:inline;
}
`);
(function($) {
//Avoid issue with global jquery
$.noConflict();
// Handlers
te_commentLinksInTabs($);
te_buttonNewComments($);
// ===== Scripts =====
// Author: Crius
function te_commentLinksInTabs($) {
// Load every external link into a new tab
$('a').click(function() {
if($(this).attr('href').indexOf("http") > -1) {
$(this).attr('target', '_blank');
}
});
}
// Author: Crius
function te_buttonNewComments($) {
if($('.is-comment-new').length) {
$(`
<input id="es_scrollToNewComments" type="button" value="Next New Comment" class="btn btn-primary fixed-bottom-right" />
`).appendTo($("body"));
$('#es_scrollToNewComments').on('click', function() { __te_scrollToNewComment() });
}
function __te_scrollToNewComment() {
if($('.is-comment-new').length) {
$('.is-comment-new')[0].scrollIntoView();
setTimeout(function() {
$('.is-comment-new')[0].classList.remove('is-comment-new');
if(!$('.is-comment-new').length) {
$('#es_scrollToNewComments').remove();
}
}, 500);
}
}
}
})($);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment