Flickr - TopPager

Inserts a pager at the top of pages which only show a pager at the bottom of the page.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// Flickr TopPager
// Copyright (c) 2010, Patrick Joseph.
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name           	Flickr - TopPager
// @namespace		http://userscripts.org/users/isamux
// @description		Inserts a pager at the top of pages which only show a pager at the bottom of the page.
// @version         1.0.6
// @date            2011-04-24
// @creator         Patrick Joseph
// @include        	http://www.flickr.com/photos/*
// @include        	http://www.flickr.com/groups/*
// @include        	http://www.flickr.com/*/favorites*
// @exclude        	http://*.flickr.com/photos/friends*
// ==/UserScript==

// ==Changelog==
//2011-04-24 v1.0.6:
// * Reduced bottom margin of navigation.
//2011-04-24 v1.0.5:
// * Adjusted IDs of paginated contents after change of HTML-structure on Flickr.
// ==/Changelog==

// ---------------
//  CONFIGURATION
// ---------------
const CONST_ENABLE_FIREBUG_LOGGING = false;
const CONST_PAGINATED_CONTENT_XPATH_PHOTOSTREAM = '//div[starts-with(@class,"PhotoStream")]';
const CONST_PAGINATED_CONTENT_XPATH_GROUP = '//div[@class="HoldPhotos"]';
const CONST_PAGINATED_CONTENT_ID_FAVORITES = 'favoriteThumbs';

// ---------------
//  SCRIPT-MAIN
// ---------------
// 0. Prepare everything
// init logging
initLogging(console);

// I. get element before which the top pager will be inserted.
oPaginatedContent = getPaginatedContent();

// II. insert top page paginator
if(oPaginatedContent != null)
{
    console.info("TopPager: Paginated content was found");
	oPaginator = getPaginator();
	oPaginatorCopy = oPaginator.cloneNode(true);
    console.info("TopPager: Bottom paginator cloned");
	oPaginatedContent.parentNode.insertBefore(oPaginatorCopy, oPaginatedContent);
    console.info("TopPager: Finished adding top Pager");
    
     // reduce bottom margin of navigation
     subNav = document.getElementById('SubNav');
     subNav.style.setProperty("margin-bottom","0","");
}

// ===============
//  FUNCTION LIB
// ===============

function getPaginatedContent()
{
	// try get that element on photostream pages, ...
	oTmpFound =  getElement(CONST_PAGINATED_CONTENT_XPATH_PHOTOSTREAM);

	if(oTmpFound == null)
	{
		//...then on groups pages
		oTmpFound = getElement(CONST_PAGINATED_CONTENT_XPATH_GROUP);
	}

	if(oTmpFound == null)
	{
		//...and finally on favorites pages.
		oTmpFound = document.getElementById(CONST_PAGINATED_CONTENT_ID_FAVORITES);
	}

	return oTmpFound;
}

function getPaginator()
{
	return getElement('//div[@class="Pages"]');
}

function getElement(exp)
{
	var xpathResult = document.evaluate(
		exp,
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
		
	return xpathResult.snapshotItem(0);
}

function initLogging(pConsole)
{
	if(typeof pConsole === "undefined" || !CONST_ENABLE_FIREBUG_LOGGING) 
	{
		console = { 	log: function() { }, 
						info: function() {}, 
						debug: function() { } ,
						warn: function() {},
						error: function() {} };
	}
}