By alto maltés
—
Last update
Dec 30, 2007
—
Installed
5,092 times.
// ==UserScript==
// @namespace tag:edward.grech.name,2007:/dev/greasemonkey
// @name Flickr disable/enable photo notes
// @description Disables notes on a Flickr photo page, and strikes out the “This photo has notes…” message. Clicking on that message then re-enables/disables notes.
// @author Edward Grech | edward@grech.name | alto maltés | http://flickr.com/people/dwardu
// @date 2007-12-30
// @version 0.1
// @include http://flickr.com/photos/*/*
// @include http://*.flickr.com/photos/*/*
// ==/UserScript==
// More info at http://flickr.com/groups/flickrhacks/discuss/72157603565687671/
// Date Version Comments
// 2007-12-30 0.1 If a page has notes but for some reason has no span[@id='noteCount'], it gets created and inserted before div[@id='DiscussPhoto']
// 2007-12-28 0.0 Original version
(function() {
if(!unsafeWindow.page_p)
return;
var notes = unsafeWindow.page_p.notesA || [];
if(notes.length == 0)
return;
var note_count_span = document.evaluate("//span[@id='noteCount']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; // "This photo has notes. Move your mouse over the photo to see them."
if(!note_count_span) { // If for some reason this photo has notes, but there is no span[@id='noteCount'], create it and insert it before div[@id='DiscussPhoto']
note_count_span = document.createElement('span');
note_count_span.setAttribute('id', 'noteCount');
note_count_span.appendChild(document.createTextNode('This photo has notes. Move your mouse over the photo to see them.'));
var discuss_photo_div = document.evaluate("//div[@id='DiscussPhoto']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
discuss_photo_div.parentNode.insertBefore(note_count_span, discuss_photo_div);
}
var photo_notes_div = document.evaluate("//div[@id='photo_notes']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
function apply_setting(enabled) {
photo_notes_div.setAttribute('style', 'display: '+(enabled ? 'block' : 'none'));
note_count_span.setAttribute('style', 'text-decoration: '+(enabled ? 'none' : 'line-through'));
}
function current_setting() {
return GM_getValue('notes_enabled', false);
}
function toggle_setting(e) {
var enabled = !current_setting();
GM_setValue('notes_enabled', enabled);
apply_setting(enabled);
alert(enabled ? 'Notes enabled.' : 'Notes disabled.');
}
note_count_span.addEventListener('click', toggle_setting, false);
note_count_span.addEventListener('mouseover', function(e) { apply_setting(!current_setting()); }, false);
note_count_span.addEventListener('mouseout', function(e) { apply_setting( current_setting()); }, false);
apply_setting(current_setting());
})();