Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Flickr Buddy Interesting - MATCH - TWEAK 2020 - NO TAMPERMONKEY (Why?) / OK VIOLENTMONKEY -
- // @namespace http://6v8.gamboni.org/
- // @description Pierre Andrews (Mortimer) - TWEAK Localize / Number of Pics displayed - 2017.06 - Quick access to user's interesting photos from the Buddy Icon Menu
- // @version 0.5
- // @identifier http://6v8.gamboni.org/IMG/js/flickrbuddyinteresting.user.js
- // @date 2009-04-17
- // @creator Pierre Andrews ([email protected])
- // @contributor Stephen Fernandez ( http://steeev.freehostia.com )
- // @contributor Ricardo Mendonca Ferreira
- //
- // @include http://*flickr.com*
- // @include http*://*flickr.com/*
- // @exclude http*://*flickr.com/groups/
- // @exclude http*://*flickr.com/photos/*/map*
- // @exclude http*://*flickr.com/photos/*/page*
- // 2019
- // @exclude http*://*flickr.com/photos/*/favorites*
- // @exclude http*://*flickr.com/photos/*/favorites/*
- // @exclude http*://*flickr.com/photos/*/albums*
- // @exclude http*://*flickr.com/groups?view=tn
- // @exclude http*://*flickr.com/groups?view=ls
- // @exclude http*://*flickr.com/groups/*/pool/*
- // @exclude http*://services.addons.mozilla.org/*
- // @grant none
- // ==/UserScript==
- // --------------------------------------------------------------------
- //
- // This is a Greasemonkey user script.
- //
- // To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
- // Then restart Firefox and revisit this script.
- // Under Tools, there will be a new menu item to "Install User Script".
- // Accept the default configuration and install.
- //
- // --------------------------------------------------------------------
- // Copyright (C) 2006 Pierre Andrews
- //
- // This program is free software; you can redistribute it and/or
- // modify it under the terms of the GNU General Public License
- // as published by the Free Software Foundation; either version 2
- // of the License, or (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // The GNU General Public License is available by visiting
- // http://www.gnu.org/copyleft/gpl.html
- // or by writing to
- // Free Software Foundation, Inc.
- // 51 Franklin Street, Fifth Floor
- // Boston, MA 02110-1301
- // USA
- debugger;
- (function () {
- //update information
- var SCRIPT = {
- name: "Flickr Buddy Interesting",
- namespace: "http://6v8.gamboni.org/",
- description: "Quick access to user's interesting photos from the Buddy Icon Menu",
- identifier: "http://6v8.gamboni.org/IMG/js/flickrbuddyinteresting.user.js",
- version: "0.5", // version
- date: (new Date("2009-04-17")) // update date
- .valueOf()
- };
- function $x1(xpath) {
- return document.evaluate(
- xpath,
- document,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null
- ).singleNodeValue;
- }
- /***********************************************************************
- * Flickr Localisation (changes TAMPERMONKEY : line 83>85 )
- **********************************************************************/
- // LOCALISATION TWEAKED
- //FlickrLocalisation, script to help localise user script for Flickr
- //version 0.2
- //release 26 Jun 2007
- //author: Pierre Andrews
- // --------------------------------------------------------------------
- // Copyright (C) 2007 Pierre Andrews
- // This script can be redistributed under the terms of the GNU LGPL, without
- // modification of this licence and copyright notice. Attribution to the author should be
- // kept at least in the source of the scripts.
- // For reference: http://6v8.gamboni.org/Localising-Flickr-Greasemonkey.html
- //
- // This program is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Lesser General Public License
- // as published by the Free Software Foundation;
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // The GNU Lesser General Public License is available by visiting
- // http://www.gnu.org/copyleft/lgpl.html
- // or by writing to
- // Free Software Foundation, Inc.
- // 51 Franklin Street, Fifth Floor
- // Boston, MA 02110-1301
- // USA
- var FlickrLocaliser = function(locals) {
- this.init(locals);
- }
- FlickrLocaliser.prototype = {
- selectedLang: undefined,
- localisations: undefined,
- getLanguage: function() {
- if(!this.selectedLang) {
- var langA = document.evaluate(
- //"//p[@class='LanguageSelector']//a[contains(@class,'selected')]",
- // TWEAK DECEMBRE
- // PB Localisation example :
- // FIXED for HELP Forum - https://www.flickr.com/help/forum/88857/?search=sans
- //"//p[@class='.ui-dropdown.simple-drop.drop-up']//a[contains(@class,'selected')]",
- ".//*[@id='foot']/footer/div/div[1]/div/ul/li[10]/div//a[contains(@class,'selected')]",
- document,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null
- ).singleNodeValue;
- if (!langA) { // new photo page layout
- var langA = document.evaluate(
- "//div[@id='foot-lang']//a[contains(@class,'selected')]",
- document,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null
- ).singleNodeValue;
- }
- if(langA) {
- var matches = /\/change_language.gne\?lang=([^&]+)&.*/.exec(langA.href);
- if(matches && matches[1]) {
- this.selectedLang = matches[1];
- return this.selectedLang;
- }
- }
- return false;
- } else return this.selectedLang;
- },
- init: function(locals) {
- this.localisations = locals;
- },
- localise: function(string, params) {
- if(this.localisations && this.getLanguage()) {
- var currentLang = this.localisations[this.selectedLang];
- if(!currentLang) currentLang = this.localisations[this.localisations.defaultLang];
- var local = currentLang[string];
- if(!local) {
- local = this.localisations[this.localisations.defaultLang][string];
- }
- if(!local) return string;
- for(arg in params) {
- var rep = new RegExp('@'+arg+'@','g');
- local = local.replace(rep,params[arg]);
- }
- local =local.replace(/@[^@]+@/g,'');
- return local;
- } else return undefined;
- }
- }
- /*****************************Flickr Localisation**********************/
- var localiser = new FlickrLocaliser({
- 'en-us' : {
- 'pool_interesting' : 'Pool Interestingness',
- 'quick_interesting' : 'Quick Interestingness',
- 'close' : 'Close'
- },
- 'fr-fr' : {
- 'pool_interesting' : 'Interestingness du Groupe',
- 'quick_interesting' : 'Interestingness Rapide',
- 'close' : 'Fermer'
- },
- 'it-it' : {
- 'pool_interesting' : 'Interestingness del Gruppo',
- 'quick_interesting' : 'Interestingness Rapida',
- 'close' : 'Chiudi'
- },
- defaultLang: 'en-us'
- });
- function M8_log() {
- if(unsafeWindow.console)
- unsafeWindow.console.log(arguments);
- else
- GM_log(arguments);
- }
- /*
- Xpath trickery, from:
- http://ecmanaut.blogspot.com/2006/07/expressive-user-scripts-with-xpath-and.html
- */
- function $x( xpath, root )
- {
- var doc = root ? root.evaluate?root:root.ownerDocument : document;
- var got = doc.evaluate( xpath, root||doc, null, 0, null ), next;
- var result = [];
- while( next = got.iterateNext() )
- result.push( next );
- return result;
- }
- function foreach( xpath, cb, root )
- {
- var nodes = $x( xpath, root ), e = 0;
- for( var i=0; i<nodes.length; i++ )
- e += cb( nodes[i], i ) || 0;
- return e;
- }
- function getObjectMethodClosure(object, method) {
- return function(arg) {
- return object[method](arg);
- }
- }
- /*
- LightWeightBox - Thom Shannon
- http://www.ts0.com
- V 1.0 2006
- BSD License
- */
- var LightWeightBoxOn=false;
- var LightWeightBox = function(ele){
- this.ele = ele;
- this.backgroundColor = '#CCC';
- this.opacity = 0.5;
- }
- with (LightWeightBox){
- prototype.Render = function(){
- if (!LightWeightBoxOn){
- bgDiv = document.createElement('div');
- bgDiv.innerHTML = ''
- bgDiv.style.backgroundColor = this.backgroundColor;
- bgDiv.style.position='fixed';
- bgDiv.style.height='100%';
- bgDiv.style.width='100%';
- bgDiv.style.top=0;
- bgDiv.style.left='0';
- bgDiv.style.opacity=this.opacity;
- this.ele.style.position='fixed';
- this.bgDiv=bgDiv;
- document.body.appendChild(this.bgDiv);
- document.body.appendChild(this.ele);
- this.CheckSize();
- LightWeightBoxOn = true;
- var oSelf=this;
- this.sizeCheck = setInterval(function(){oSelf.CheckSize();},20);
- }
- }
- prototype.CheckSize = function(){
- if (this.ele.offsetHeight!=this.currentHeight) {
- this.offsetTop = (self.innerHeight/2)-(this.ele.offsetHeight/2);
- this.ele.style.top = this.offsetTop+'px';
- this.currentHeight=this.ele.offsetHeight;
- }
- if (this.ele.offsetWidth!=this.currentWidth) {
- this.offsetLeft = (self.innerWidth/2)-(this.ele.offsetWidth/2);
- this.ele.style.left = this.offsetLeft+'px';
- this.currentWidth=this.ele.offsetWidth;
- }
- }
- prototype.Close=function(oSelf){
- document.body.removeChild(oSelf.bgDiv);
- document.body.removeChild(oSelf.ele);
- LightWeightBoxOn = false;
- }
- }
- var flickrbuddyinteresting = function() {this.init();}
- flickrbuddyinteresting.prototype = {
- init: function() {
- var menu = document.getElementById('personmenu_contacts_link');
- if(menu) {
- var link =document.createElement('a');
- link.setAttribute('class','block');
- link.setAttribute('id','tag_person_link');
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('quick_interesting');
- menu.parentNode.insertBefore(link,menu.nextSibling);
- }
- // decembre CONTACTS page - OK
- //var who = getElementsByClassName('Icon');
- //var menu = getElementsByClassName('personmenu-sep-bottom');
- // <head>
- // <title>Who calls you a contact? | Contacts | flickr.com</title>
- // <td class="contact-list-bicon">
- // <a rel="contact" href="/photos/muhammetsen/">
- // <img class="BuddyIconX" width="24" height="24" border="0" alt="senmuhammet" src="https://farm8.staticflickr.com/7122/buddyicons/[email protected]?1462861443#135724433@N06">
- // div id="person_hover" style="left: 242px; top: 107px; display: block;">
- // <div id="person_hover_shadow" class="shadowDark"></div>
- // <div id="person_hover_inner">
- // <a id="person_hover_link" href="https://www.flickr.com/photos/muhammetsen/" style="display: block;">
- // <img id="hover_img135458416@N03" class="person_hover_img">
- // <img id="hover_img135724433@N06" class="person_hover_img" src="https://farm8.staticflickr.com/7122/buddyicons/[email protected]?1462861443#135724433@N06" style="display: block; visibility: visible;" title="">
- // OK - CONTACTS PAGES - https://www.flickr.com/people/75967505@N03/contacts/
- var title = document.getElement('Who');
- if(title) {
- var link =document.createElement('a');
- link.setAttribute('class','block');
- link.setAttribute('id','tag_person_link');
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('quick_interesting');
- // TEST COR title
- // menu.parentNode.insertBefore(link,menu.nextSibling);
- title.parentNode.insertBefore(link,menu.nextSibling);
- }
- // decembre TEST PHOTO PAGE - NOT WORKING
- // .Icon
- //var userinfo = getElementsByClassName('Icon');
- // .avatar.person.medium
- // var userinfo = getElementsByClassName('avatar.person.medium');
- // var userinfo = getElementsByClassName('avatar');
- // .personmenu-sep-bottom
- //var userinfo = getElementsByClassName('personmenu-sep-bottom');
- // .personCardMessageClick
- // var userinfo = document.getElement('personCardMessageClick');
- // var userinfo = getElementsByClassName('personCardMessageClick');
- // .align-right
- // var userinfo = getElementsByClassName('align-right');
- // .attribution-info
- // var userinfo = document.getElement('attribution-info');
- // .owner-name
- // var userinfo = document.getElement('owner-name');
- // var userinfo = getElementsByClassName('owner-name');
- // .attribution.shorter>a
- // var userinfo = document.getElement('attribution.shorter>a');
- //
- /*
- // 2019 TEST - NOT WORKING - PHOTO PAGES - https://www.flickr.com/people/75967505@N03/contacts/
- var menu3 = document.querySelector('.links.secondary a[href^="/people/"]');
- if(menu3) {
- var link =document.createElement('a');
- link.setAttribute('class','block');
- link.setAttribute('id','tag_person_link');
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('quick_interesting');
- // TEST COR title
- // menu.parentNode.insertBefore(link,menu.nextSibling);
- title.parentNode.insertBefore(link,menu.nextSibling);
- }
- // var person-card-view = document.getElement('attribution.shorter>a');
- */
- // TEST - USERINFO - NOT WORKING ?
- if(userinfo) {
- // if(person-card-view) {
- var link =document.createElement('a');
- link.setAttribute('class','block');
- link.setAttribute('id','tag_person_link');
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('quick_interesting');
- // TEST - COR userinfo
- // menu.parentNode.insertBefore(link,userinfo.nextSibling);
- userinfo.parentNode.insertBefore(link,userinfo.nextSibling);
- // .view.person-card-view
- // menu.parentNode.insertBefore(link,person-card-view.nextSibling);
- }
- // END TEST PHOTO PAGE
- // POOLS - NOT WORKING ?
- if(document.location.href.match(/\/groups\//) && unsafeWindow.document.getElementById('SubNav')) {
- psi=$x1('//p[@class="LinksNewP"]');
- psi.innerHTML+=' <img src="/images/subnavi_dots.gif" alt="" height="11" width="1"> ';
- var link =document.createElement('a');
- link.setAttribute('class','block');;
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('pool_interesting');
- psi.appendChild(link);
- }
- // END POOLS - NOT WORKING ?
- // PROFILE - NOT WORKING ?
- var menu2 = document.getElementById('button-bar');
- if(profile) {
- var link =document.createElement('a');
- link.setAttribute('class','block');
- link.setAttribute('id','tag_person_link');
- link.setAttribute('href','javascript:;');
- link.addEventListener('click',getObjectMethodClosure(this,'showInteresting'),true);
- link.textContent=localiser.localise('quick_interesting');
- menu2.parentNode.insertBefore(link,menu2.nextSibling);
- }
- // END - PROFILE - NOT WORKING ?
- },
- showInteresting: function(ev) {
- // create a block element of some kind
- var boxEle = document.createElement('div');
- var ul = boxEle.appendChild(document.createElement('ul'));
- // style it up with a class or inline
- boxEle.className = 'popup';
- // create something to act as a close button
- btnClose = document.createElement('a');
- btnClose.href='javascript:;';
- btnClose.innerHTML=localiser.localise('close');
- // add close button to block element
- boxEle.appendChild(btnClose);
- // create box with block element
- var lwBox = new LightWeightBox(boxEle);
- // optional bg color and opacity
- boxEle.style.paddingTop= '20px';
- boxEle.style.width= (75*5+20)+'px';
- boxEle.style.height= (75*5+40)+'px';
- boxEle.style.backgroundColor = '#333';
- // attach close event and add your own code
- btnClose.addEventListener('click',function(){
- // you have to pass box object into event
- // because of the js event scoping
- lwBox.Close(lwBox);
- // false to cancel link
- return false;
- },true);
- btnClose.setAttribute('style','background-color:#CCC;');
- ul.setAttribute('style','margin:0;padding:0;list-style-type:none;');
- var self = this;
- var listener = {
- flickr_photos_search_onLoad: function(success, responseXML, responseText, params){
- try{
- var rsp = responseText.replace(/jsonFlickrApi\(/,'');
- rsp = eval('('+rsp);
- if(rsp.stat == 'ok') {
- var i=0;
- var html = '';
- for(i=0;i<rsp.photos.photo.length;i++) {
- var photo = rsp.photos.photo[i];
- html += '<li style="margin:0;padding:0;display:inline;"><a href="https://www.flickr.com/photos/'+photo.owner+'/'+photo.id+'/"><img title=""' + photo.title + '" by ' + photo.ownername + '" src="https://farm'+photo.farm+'.static.flickr.com/'+photo.server+'/'+photo.id+'_'+photo.secret+'_s.jpg" width="75" height="75"/></a></li>';
- }
- ul.innerHTML = html;
- // render it!
- lwBox.Render();
- } else
- M8_log("Error2 "+responseText);
- } catch (e) {
- M8_log("Error1 "+responseText);
- M8_log(e);
- }
- }
- };
- // TWEAKED 25 > 150 or 250 or 622 pics == seems 500 only possible by page
- var block = ev.target.parentNode;
- var matches = /mail\/write\/\?to=([^"]*)"/.exec(block.innerHTML);
- if(matches)
- unsafeWindow.F.API.callMethod('flickr.photos.search', {
- // user_id: matches[1], sort: 'interestingness-desc', page:1, per_page: 253,
- user_id: matches[1], sort: 'interestingness-desc', page:1, per_page: 722,
- format: 'json', extras: 'owner_name'
- }, listener);
- if(ev.target.textContent==localiser.localise('pool_interesting')) {
- thegroupid=unsafeWindow.document.getElementById('SubNav').innerHTML.split('\/buddyicons\/')[1].split('\.jpg')[0];
- unsafeWindow.F.API.callMethod('flickr.photos.search', {
- // group_id: thegroupid , sort: 'interestingness-desc', page:1, per_page: 253,
- group_id: thegroupid , sort: 'interestingness-desc', page:1, per_page: 700,
- format: 'json', extras: 'owner_name'
- }, listener);
- }
- }
- }
- //======================================================================
- // launch
- try {
- window.addEventListener("load", function () {
- try {
- // update automatically (http://userscripts.org/scripts/show/2296)
- win.UserScriptUpdates.requestAutomaticUpdates(SCRIPT);
- } catch (ex) {}
- var flickrgp = new flickrbuddyinteresting();
- }, false);
- } catch (ex) {}
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement