Changeset 11552

Show
Ignore:
Timestamp:
05/14/08 09:41:38 (5 years ago)
Author:
mattn
Message:

* FullFeed?.addPreFilterを追加し、GoogleReaderのエントリ表示時にフックをかけられる様にした。
* registerWidgetsをpreFilterに登録
* registerSbmIconsをpreFilterに登録

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/googlereaderfullfeed.user.js

    r10423 r11552  
    66// @description loading full entry on Google Reader 
    77// @privilege   false 
    8 // @version     0.1.6 
     8// @version     0.1.7 
    99// ==/UserScript== 
    1010// based on: LDR Full Feed <http://d.hatena.ne.jp/toshi123> 
     
    300300    icon = document.createElement('span'); 
    301301    icon.title = description; 
    302     icon.innerHTML = '<img src="'+ICON+'">'; 
     302    icon.innerHTML = '<img src="'+ICON+'" style="cursor: pointer;">'; 
     303    icon.addEventListener('click', init, false); 
    303304    w.addClass(icon, 'gm_fullfeed_checked'); 
    304305    container.appendChild(document.createTextNode(' ')); 
     
    306307    if (autoLoad) init(); 
    307308  } 
     309}; 
     310 
     311FullFeed.registerSbmIcons = function() { 
     312  if (!WIDGET) return; 
     313  var container = getFirstElementByXPath('id("current-entry")//a[contains(concat(" ",normalize-space(@class)," ")," entry-title-link ")]').parentNode; 
     314  if (!container) return; 
     315 
     316  var c = new getCurrentItem(); 
     317  icon = document.createElement('span'); 
     318  icon.innerHTML = '' 
     319    + '&nbsp;<img src="http://b.hatena.ne.jp/entry/image/' + c.item.link + '"/>' 
     320    + '&nbsp;<img src="http://image.clip.livedoor.com/counter/' + c.item.link + '"/>' 
     321  container.appendChild(icon); 
    308322}; 
    309323 
     
    320334]; 
    321335 
     336FullFeed.preFilters = [ 
     337  FullFeed.registerWidgets, 
     338  FullFeed.registerSbmIcons, 
     339]; 
     340 
    322341FullFeed.filters = []; 
    323342 
     
    326345window.FullFeed.addDocumentFilter = function(f) { 
    327346  FullFeed.documentFilters.push(f); 
     347}; 
     348 
     349window.FullFeed.addPreFilter = function(f) { 
     350  FullFeed.preFilters.push(f); 
    328351}; 
    329352 
     
    445468var pattern; 
    446469var autoLoad = false; 
     470var lastItem = null; 
    447471 
    448472GM_registerMenuCommand('Google Reader Full Feed - reset cache', FullFeed.resetCache); 
     
    466490  if (timer) clearTimeout(timer); 
    467491  try { 
    468     var container = getFirstElementByXPath('id("current-entry")//a[contains(concat(" ",normalize-space(@class)," ")," entry-title-link ")]'); 
    469     var icon = getFirstElementByXPath('id("current-entry")//span[contains(concat(" ",normalize-space(@class)," ")," gm_fullfeed_checked ")]'); 
    470     if (container && !icon) { 
    471       FullFeed.registerWidgets(); 
    472     } 
     492    var currentItem = w.get_active_item(true); 
     493    if (!lastItem || lastItem.link != currentItem.link) { 
     494      lastItem = currentItem; 
     495      FullFeed.preFilters.forEach(function(filter) { 
     496        filter(currentItem); 
     497      }); 
     498    }   
    473499  } catch (e) {} 
    474500  timer = setTimeout(arguments.callee, 200);