Eza's Gallery Smoothener

Removes unimportant links below thumbnails, so select -> right-click -> open-links-in-new-tabs works cleanly.

Versione datata 23/12/2016. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        Eza's Gallery Smoothener
// @namespace    https://inkbunny.net/ezalias
// @author			Ezalias
// @description     Removes unimportant links below thumbnails, so select -> right-click -> open-links-in-new-tabs works cleanly. 
// @license     MIT
// @include     http://www.furaffinity.net/msg/submissions/*
// @include     http://www.furaffinity.net/favorites/*
// @include     https://inkbunny.net/submissionsviewall.php*mode=unreadsubs*
// @include     https://inkbunny.net/submissionsviewall.php*mode=userfavs*
// @include     http://www.hentai-foundry.com/users/FaveUsersRecentPictures?username=*
// @include     http://www.hentai-foundry.com/pictures/*
// @exclude    /^http://www\.hentai-foundry\.com/pictures/.*/.*/[0-9]*/.*/
// @include     https://www.weasyl.com/messages/submissions*
// @include     https://www.weasyl.com/submissions*
// @include     https://www.weasyl.com/favorites*
// @include     http://www.y-gallery.net/gallery/*
// @include     http://www.y-gallery.net/favourites/*
// @include     http://www.y-gallery.net/browse/
// @include     http://www.y-gallery.net/browsetops/ 
// @include     http://www.y-gallery.net/clubgallery/*
// @include     http://rule34.paheal.net/post/list/*
// @include     http://www.pixiv.net/bookmark_new_illust.php?*
// @include     http://www.pixiv.net/bookmark.php?*
// @include     http://www.pixiv.net/member_illust.php?*
// @exclude    http://www.pixiv.net/member_illust.php?mode*
// @include     http://*.deviantart.com/gallery/*
// @version     1.10 
// @grant       none
// ==/UserScript==

// This removes user-profile links and other extraneous junk from supported image galleries so that users can select many images and open them all in tabs.
// This only matters if your browser has some extension to select multiple links and "Open links in tabs." 

// Todo: support relevant sites from Eza's Image Glutton - mostly "watching" pages and "favorites" galleries. 
// Linked images seem to disappear, even though they ought to be handled by innerHTML. 
// SoFurry requires additional handling thanks to their dynamic page shenanigans. (Be restful, you stupid document!) 
// Maybe Derpibooru? They have comment / vote links above every thumbnail. 
// DeviantArt pools are kind of a pain. 
// Can the DOM change an element's tag name? Can I just 'a' -> 'span' for the relevant links? (Seems not.) 
// Apparently data-whatever-etc attributes are handled super specially by JS: it's thing.dataset.whateverEtc. Yes, it automatically converts to camelcase. Jesus. 
// Fix FurAffinity before uploading? Augh, it's some kind of imaginary inline iframe. Guess I'm stuck with titles off. 

// For Pixiv specifically:
if( document.domain == "www.pixiv.net" ) { 		// Pixiv JS creates create "Report" links from image classnames, so we immediately remove classnames from each image
	var thumbnails = document.body.getElementsByTagName( "img" ); 
	for( let x = thumbnails.length-1; x > 0; x-- ) { 
		thumbnails[x].className = "";
		if( thumbnails[x].dataset.src ) { thumbnails[x].src=thumbnails[x].dataset.src; } 		// Bookmark thumbnails are blank until Pixiv JS uses data-src. Why? It is a mystery.
	} 
}

// For all sites:
var links = document.getElementsByTagName( 'a' ); 		// Grab all links.
for( var n = links.length-1; n >= 0; n-- ) { 		// For each link, 
	if( username_link_in( links[n] ) ) { 		// If it points to a user's profile,
			// Replace it with unlinked text. 
		var dud = document.createElement("span"); 			// I.e. - create blank span,
		for( var x in links[n] ) { dud[x] = links[n][x]; } 		 	// Copy all elements of this link onto this span, 
		links[n].parentNode.replaceChild( dud, links[n] ); 		// Replace this link with this span. 
	}
}		// Done.




// -------------------------



function username_link_in( anchor ) { 		// True / False: does this link element look like a userpage link? 
	switch( document.domain ) { 
		case "www.furaffinity.net":  		// FA: yes, if it contains "/user/username". (Also for "deleted by the owner" fake-links.) 
			return anchor.href.indexOf( "/user/" ) > 0 || anchor.href.indexOf( "/favorites/" ) >= 0; break;
		case "inkbunny.net": 		// IB: yes, if the messy class string includes a userName designation. 
			return anchor.className.indexOf( "userName" ) > 0; break;
		case "www.hentai-foundry.com":		// HF: yes, if it contains "/user/username/profile". (Every HF link has /user/ in it. Grr.) 
			return anchor.href.indexOf( "/profile" ) > 0; break; 
		case "www.weasyl.com": 		// Weasy: yes, if it contains... tilde? I don't even remember writing this one. Am I on Weasyl? 
			return anchor.href.indexOf( "~" ) > 0; break;
		case "www.y-gallery.net": 		// YG: yes, if it contains "/user/username" or "/club/clubname". 
			return anchor.href.indexOf( "/user/" ) > 0 || anchor.href.indexOf( "/club/" ) > 0; break;
		case "rule34.paheal.net": 		// Paheal: yes, if it's a bare image link. (Or a weird invisible same-page anchor.) 
			return anchor.href.indexOf( "_images" ) > 0 || anchor.href[ anchor.href.length - 1 ] == "#"; break;
		case "www.pixiv.net":		// Pixiv: yes, if it's a username, bookmark stats, or bookmark-tag-editing link. (This breaks tag editing. Sorry.) 
			return ( anchor.href.indexOf( "member_illust.php?id" ) > 0 && window.location.href.indexOf( "member_illust.php?id" ) < 0 ) 		// Ignore this on Works pages
				|| ( anchor.href.indexOf( "bookmark_detail.php?" ) > 0 ) 
				|| ( anchor.href.indexOf( "bookmark_add.php?" ) > 0 )
			break;
	}
	if( document.domain.indexOf( '.deviantart.com' ) > -1 ) { 		// Fucking subdomains. 
		return ( anchor.href.indexOf( '#comments' ) > -1 || anchor.href.indexOf( '/morelikethis/' ) > -1 ); 		// DeviantArt: yes for "comments" and "more like this." 
	}
}