// ==UserScript== // @namespace Onge's Neocities Feed Enhancer // @description a simple script that enhances the neocities feed. // @name Onge's Neocities Feed Enhancer // @author Ongezell // @homepage https://ongezell.com/ // @match https://neocities.org/ // @match https://neocities.org/site/* // @match https://neocities.org/dashboard // @exclude https://neocities.org/site/*/stats // @exclude https://neocities.org/site/*/stats?days=sincethebigbang // @exclude https://neocities.org/site/*/stats?days=365 // @exclude https://neocities.org/site/*/stats?days=90 // @exclude https://neocities.org/site/*/stats?days=30 // @exclude https://neocities.org/site/*/stats?days=7 // @match https://neocities.org/?activity=mine // @match https://neocities.org/activity // @match https://neocities.org/browse // @require https://code.jquery.com/jquery-3.6.0.min.js // @match https://neocities.org/?page=* // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-zoom/1.7.21/jquery.zoom.min.js // @grant GM_addStyle // @grant GM_addElement // @version 3.5 // ==/UserScript== var jq360 = $.noConflict(true); jq360(document).ready(function() { const $toggleButton = jq360('Dark Mode'); $toggleButton.css({ position: 'fixed', bottom: '20px', right: '20px', padding: '10px', 'background-color': '#000', color: '#fff', 'font-size': '16px', 'font-weight': 'bold', 'border-radius': '5px', border: 'none', 'z-index': '10000' }); jq360('body').append($toggleButton); let darkModeOn = localStorage.getItem('darkModeOn') === 'true'; if (darkModeOn) { setDarkModeOn(); } $toggleButton.on('click', function() { darkModeOn = !darkModeOn; if (darkModeOn) { setDarkModeOn(); localStorage.setItem('darkModeOn', 'true'); } else { setDarkModeOff(); localStorage.removeItem('darkModeOn'); } }); function setDarkModeOn() { jq360('html').css('filter', 'invert(1)'); jq360('html img, .large-portrait, .avatar, .header-Outro, .header-Nav, .zoomImg, .img-Holder, iframe').css('filter', 'invert(1)'); } function setDarkModeOff() { jq360('html').css('filter', 'none'); jq360('html img, .large-portrait, .avatar, .header-Outro, .header-Nav, .zoomImg, .img-Holder, iframe').css('filter', 'none'); } }); var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` .spoiler-button { display: block; margin: 0 auto; text-align: center; background-color: black; border: none; padding: 10px 20px; } .spoiler-button::before { content: "Spoiler"; font-size: 10px; display: block; margin: 0 auto; text-align: center; border: none; color: white; } .news-item.comment .content{ white-space: pre-line; } .news-item.comment .content .comments, .news-item.comment .content .actions { white-space: normal; } .formHax{ width: 80%; max-height: unset; } .spoiler-button:hover { background-color: grey; } .reverse-comments-button{ margin-left: 10px; } `; document.head.appendChild(style); (function(jq360) { 'use strict'; jq360(document).ready(function() { var inputField = jq360('.post-comment form input[name="message"]'); if (inputField.length > 0) { var textarea = jq360('') .attr('class', 'formHax') .attr('name', 'message') .attr('placeholder', 'Post a message...') .attr('autocomplete', 'off') .attr('maxlength', '420'); textarea.val(inputField.val()); inputField.replaceWith(textarea); } var postButton = jq360('') .addClass('btn-Action') .text('Post'); postButton.on('click', function(event) { event.preventDefault(); }); }); })(jq360); document.body.innerHTML = document.body.innerHTML.replace(/\(spoiler\)/g, '(spoiler)'); document.body.innerHTML = document.body.innerHTML.replace(/\(spoiler_\)/g, '(spoiler_)'); jq360(document).ready(function() { jq360('.spoiler-button').click(function() { jq360('.spoiler-content').toggle(); }); }); function reverseCommentOrder(eventId) { var commentsDiv = document.querySelector('#event_' + eventId + ' .comments'); var commentAndActionsDivs = commentsDiv.querySelectorAll('.comment, .actions'); var commentDivs = []; var actionsDivs = []; commentAndActionsDivs.forEach(div => { if (div.classList.contains('comment')) { commentDivs.push(div); } else { actionsDivs.push(div); } }); var reversedCommentDivs = commentDivs.reverse(); var reversedActionsDivs = actionsDivs.reverse(); reversedCommentDivs.forEach(div => div.remove()); reversedActionsDivs.forEach(div => div.remove()); reversedCommentDivs.forEach((div, index) => { commentsDiv.appendChild(div); commentsDiv.appendChild(reversedActionsDivs[index]); }); } jq360(document).ready(function() { jq360('.news-item.comment .actions:not(.comments .actions)').each(function() { var eventId = jq360(this).attr('id') ? jq360(this).attr('id').split('_')[1] : null; if (!eventId) { return; } var numComments = jq360('#event_' + eventId + ' .comments .comment').length; var toggleButtonText = 'See more comments'; if (numComments == 0) { toggleButtonText = 'No comments'; } else if (numComments == 1) { toggleButtonText = '1 comment'; } else { toggleButtonText += ' (' + numComments + ')'; } jq360(this).append('' + toggleButtonText + ''); jq360(this).append('New comments first'); jq360(this).find('.reverse-comments-button').hide(); jq360('#event_' + eventId + ' .comments .comment:not(:first-child)').hide(); jq360('#event_' + eventId + ' .comments .actions a:not(#reply)').hide(); jq360(this).find('.toggle-comments-button').click(function() { var toggleButton = jq360(this); jq360('#event_' + eventId + ' .comments .comment:not(:first-child)').toggle(function() { if (jq360(this).is(':visible')) { toggleButton.text('Hide comments'); } else { toggleButton.text(toggleButtonText); } }); jq360('#event_' + eventId + ' .comments .actions a:not(#reply)').toggle(); jq360(this).siblings('.reverse-comments-button').toggle(); }); jq360(this).find('.reverse-comments-button').click(function() { var button = jq360(this); if (button.text() === 'New comments first') { button.text('Old comments first'); } else { button.text('New comments first'); } reverseCommentOrder(eventId); }); }); }); jq360(document).ready(function() { jq360('.news-item.update').each(function() { var updateDiv = jq360(this); var firstActions = updateDiv.find('.actions').eq(0); var commentsDiv = updateDiv.find('.comments'); var numComments = commentsDiv.find('.comment').length; var toggleButtonText = 'See more comments'; if (numComments == 0) { toggleButtonText = 'No comments'; } else if (numComments == 1) { toggleButtonText = '1 comment'; } else { toggleButtonText += ' (' + numComments + ')'; } commentsDiv.find('.comment, .actions').not(':first-child').hide(); firstActions.append('' + toggleButtonText + ''); firstActions.append('New comments first'); firstActions.find('.reverse-comments-button').hide(); firstActions.find('.toggle-comments-button').click(function() { var toggleButton = jq360(this); commentsDiv.find('.comment:not(:first-child), .actions:not(:first-child)').toggle(function() { if (jq360(this).is(':visible')) { toggleButton.text('Hide comments'); } else { toggleButton.text(toggleButtonText); } }); firstActions.siblings('.reverse-comments-button').toggle(); }); firstActions.find('.reverse-comments-button').click(function() { var button = jq360(this); if (button.text() === 'New comments first') { button.text('Old comments first'); } else { button.text('New comments first'); } reverseCommentOrderForUpdate(updateDiv); }); }); }); function reverseCommentOrderForUpdate(updateDiv) { var commentsDiv = updateDiv.find('.comments'); var commentAndActionsDivs = commentsDiv.find('.comment, .actions'); var commentDivs = []; var actionsDivs = []; commentAndActionsDivs.each(function() { var div = jq360(this); if (div.hasClass('comment')) { commentDivs.push(div); } else { actionsDivs.push(div); } }); var reversedCommentDivs = commentDivs.reverse(); var reversedActionsDivs = actionsDivs.reverse(); reversedCommentDivs.each(function() { commentsDiv.append(jq360(this)); }); reversedActionsDivs.each(function() { commentsDiv.append(jq360(this)); }); } document.body.innerHTML = document.body.innerHTML.replace(/\(br\)/g, '(br)'); document.body.innerHTML = document.body.innerHTML.replace(/\(p\)/g, '(p)'); document.body.innerHTML = document.body.innerHTML.replace(/\(p_\)/g, '(p_)'); document.body.innerHTML = document.body.innerHTML.replace(/\(h1\)/g, '(h1)'); document.body.innerHTML = document.body.innerHTML.replace(/\(h1_\)/g, '(h1_)'); document.body.innerHTML = document.body.innerHTML.replace(/\(center\)/g, '(center)'); document.body.innerHTML = document.body.innerHTML.replace(/\(center_\)/g, '(center_)'); document.body.innerHTML = document.body.innerHTML.replace(/\(style=([^)]+)\)/g, '(style=$1)'); document.body.innerHTML = document.body.innerHTML.replace(/\(style_\)/g, '(style_)'); jq360('a[href*="youtube.com"], a[href*="youtu.be"]').each(function() { var youtubeLink = jq360(this).attr('href'); var videoId; if (youtubeLink.includes('youtube.com')) { videoId = youtubeLink.split('v=')[1]; } else if (youtubeLink.includes('youtu.be')) { videoId = youtubeLink.split('.be/')[1]; } if (videoId) { GM_addElement(this.parentNode, 'iframe', { src: 'https://youtube.com/embed/' + videoId, style: 'width: 100%; height: 500px;', frameborder: '0' }); } }); jq360('a[href$=".jpg"], a[href$=".png"], a[href$=".gif"], a[href$=".jpeg"], a[href$=".bmp"], a[href$=".webp"], a[href$=".mp4"], a[href$=".webm"]').each(function() { var link = jq360(this).attr('href'); var elementType; if (link.match(/\.(jpg|jpeg|png|gif|bmp|webp)$/i)) { elementType = 'img'; } else if (link.match(/\.(mp4|webm)$/i)) { elementType = 'video'; } if (elementType === 'img') { GM_addElement(this.parentNode, 'img', { src: link, class: 'imgus', style: 'width: auto; height: auto;' }); } // else if (elementType === 'video') { // GM_addElement(this.parentNode, 'video', { // src: link, // style: 'width: 100%; height: auto;' // }); // } }); jq360('.imgus').zoom({ }); jq360('a#like').hover(function(e) { var title = jq360(this).attr('data-original-title'); if (title === '') { return; } var names = title.split(''); var list = ''; for (var i = 0; i < names.length; i++) { list += '' + names[i] + ''; } var $tooltip = jq360('').css({ 'position': 'absolute', 'top': e.pageY + 10 + 'px', 'left': e.pageX + 20 + 'px', 'background-color': 'lightblue', 'box-shadow': '0 0 5px rgba(0, 0, 0, 0.1)', 'border-radius': '5px', 'padding': '10px', 'opacity': '0', 'transition': 'opacity 0.5s' }).html('' + list + ''); jq360('body').append($tooltip); $tooltip.css('opacity', '1'); }, function() { jq360('.tooltip-custom').remove(); }); jq360('a.comment_like').hover(function(e) { var title = jq360(this).attr('data-original-title'); if (title === '') { return; } var names = title.split(''); var list = ''; for (var i = 0; i < names.length; i++) { list += '' + names[i] + ''; } var $tooltip = jq360('').css({ 'position': 'absolute', 'top': e.pageY + 10 + 'px', 'left': e.pageX + 20 + 'px', 'background-color': 'lightblue', 'box-shadow': '0 0 5px rgba(0, 0, 0, 0.1)', 'border-radius': '5px', 'padding': '10px', 'opacity': '0', 'transition': 'opacity 0.5s' }).html('' + list + ''); jq360('body').append($tooltip); $tooltip.css('opacity', '1'); }, function() { jq360('.tooltip-custom').remove(); });
(p)'); document.body.innerHTML = document.body.innerHTML.replace(/\(p_\)/g, '