Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name NHentai Comment Gallery Linker
- // @namespace https://nhentai.net/
- // @version 1.0
- // @description Adds a link to the gallery for each comment on NHentai user pages
- // @author erasels
- // @match https://nhentai.net/users/*/*
- // @icon https://nhentai.net/favicon.ico
- // @license none
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Select all comments
- document.querySelectorAll('.comment').forEach(comment => {
- try {
- // Extract the data-state attribute which contains JSON
- const dataState = JSON.parse(comment.getAttribute('data-state'));
- // Ensure gallery_id exists
- if (dataState && dataState.gallery_id) {
- const galleryId = dataState.gallery_id;
- const galleryLink = `https://nhentai.net/g/${galleryId}`;
- // Find the timestamp element
- const timeElement = comment.querySelector('.header .left time');
- if (timeElement) {
- // Create a link element
- const linkElement = document.createElement('a');
- linkElement.href = galleryLink;
- linkElement.textContent = ' [View Gallery]';
- linkElement.style.marginLeft = '5px';
- linkElement.style.color = 'gray';
- linkElement.style.fontWeight = 'bold';
- // Append the link next to the time element
- timeElement.parentNode.appendChild(linkElement);
- }
- }
- } catch (error) {
- console.error('Error processing comment:', error);
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment