Changeset 7404

Show
Ignore:
Timestamp:
03/03/08 18:58:05 (5 years ago)
Author:
drry
Message:

lang/javascript/userscripts/googlereaderfullfeed.user.js:

  • fixed a message problem on Fx 3.
  • cleaned up.
Files:
1 modified

Legend:

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

    r7401 r7404  
    1212// author: mattn <mattn.jp@gmail.com> 
    1313 
    14 var w = unsafeWindow || this; 
    15 w.onload = function() { 
    16   googleReaderFullFeed(); 
    17 }; 
    18  
    19 function googleReaderFullFeed() { 
    20  
     14(function(w) { 
    2115// == [CSS] ========================================================= 
    2216const CSS = <><![CDATA[ 
     
    121115    relativeToAbsolutePath(htmldoc, this.itemInfo.itemURL); 
    122116  } 
    123   for (var i = 0, l = FullFeed.documentFilters.length; i < l; ) { 
    124     FullFeed.documentFilters[i++](htmldoc, this.itemInfo.itemURL, this.info); 
    125   } 
     117  for (var i = 0, l = FullFeed.documentFilters.length; i < l; 
     118    FullFeed.documentFilters[i++](htmldoc, this.itemInfo.itemURL, this.info)); 
    126119  try { 
    127120    var entry = getElementsByXPath(this.info.xpath, htmldoc); 
    128   } 
    129   catch (e) { 
     121  } catch (e) { 
    130122    message(e); 
    131123    return; 
     
    135127    this.removeEntry(); 
    136128    entry = this.addEntry(entry); 
    137     for (var i = 0, l = FullFeed.filters.length; i < l; ) { 
    138       FullFeed.filters[i++](entry); 
    139     } 
     129    for (var i = 0, l = FullFeed.filters.length; i < l; 
     130      FullFeed.filters[i++](entry)); 
    140131    this.requestEnd(); 
    141132  } else { 
     
    186177  }; 
    187178  var info = {}; 
    188   for(var i = lines.length; i > 0; ) { 
     179  for (var i = lines.length; i > 0; ) { 
    189180    if (reg.test(lines[--i])) { 
    190181      info[RegExp.$1] = trimspace(RegExp.$2); 
     
    198189      } 
    199190    } 
    200     try{ 
     191    try { 
    201192      new RegExp(info.url); 
    202193    } catch (e) { 
     
    251242 
    252243 
    253 FullFeed.getCache = function() { 
    254   return eval(GM_getValue('cache')) || {}; 
     244FullFeed.getCache = function(key, oDefault) { 
     245  return eval(GM_getValue(key || 'cache', oDefault || "({})")); 
    255246}; 
    256247 
     
    258249  if (!WIDGET) return; 
    259250  var exps = []; 
    260   for (var i = 0, l = SITE_INFO.length; i < l; ) { 
    261     exps.push(SITE_INFO[i++].url); 
    262   } 
     251  for (var i = 0, l = SITE_INFO.length; i < l; exps.push(SITE_INFO[i++].url)); 
    263252  for (var url in cacheInfo) { 
    264253    var site = cacheInfo[url]; 
    265     for (var i = 0, l = site.info.length; i < l; ) { 
    266       exps.push(site.info[i++].url); 
    267     } 
     254    for (var i = 0, l = site.info.length; i < l; exps.push(site.info[i++].url)); 
    268255  } 
    269256  pattern = exps.join('|'); 
     
    415402 
    416403  if (!c.find) { 
    417     for (var i = 0, l = SITEINFO_IMPORT_URLS.length; i < l && !c.find; ) { 
    418       launchFullFeed(cacheInfo[SITEINFO_IMPORT_URLS[i++]].info, c); 
    419     } 
     404    for (var i = 0, l = SITEINFO_IMPORT_URLS.length; i < l && !c.find; 
     405      launchFullFeed(cacheInfo[SITEINFO_IMPORT_URLS[i++]].info, c)); 
    420406  } 
    421407 
     
    457443function removeXSSRisks(htmldoc) { 
    458444  var attr = "allowScriptAccess"; 
     445 
    459446  Array.forEach(htmldoc.getElementsByTagName("embed"), function(embed) { 
    460447    embed.hasAttribute(attr) && embed.setAttribute(attr, "never"); 
     
    469456  var current = base.replace(/\/[^\/]+$/, '/'); 
    470457 
    471   Array.forEach(htmldoc.getElementsByTagName("a"), function(elm) { 
    472     if(elm.getAttribute("href")) elm.href = _rel2abs(elm.getAttribute("href"), top, current); 
     458  Array.forEach(htmldoc.getElementsByTagName("a"), function(a) { 
     459    if (a.getAttribute("href")) 
     460      a.href = _rel2abs(a.getAttribute("href"), top, current); 
    473461  }); 
    474   Array.forEach(htmldoc.getElementsByTagName("img"), function(elm) { 
    475     if(elm.getAttribute("src")) elm.src = _rel2abs(elm.getAttribute("src"), top, current); 
     462  Array.forEach(htmldoc.getElementsByTagName("img"), function(img) { 
     463    if (img.getAttribute("src")) 
     464      img.src = _rel2abs(img.getAttribute("src"), top, current); 
    476465  }); 
    477466} 
     
    513502  flash.id = 'FLASH_MESSAGE'; 
    514503  hide(flash); 
    515   document.body.appendChild(flash); 
     504  document.documentElement.appendChild(flash); 
    516505  var canceler; 
    517506  this.showFlashMessageWindow = function(string, duration) { 
     
    567556  //w.message(""); w.message(mes); 
    568557  //console.log(mes); 
     558  FlashMessage.showFlashMessageWindow(""); 
    569559  FlashMessage.showFlashMessageWindow(mes, 1000); 
    570560} 
     
    573563function getElementsByXPath(xpath, node) { 
    574564  var node = node || document; 
    575   var doc = node.ownerDocument ? node.ownerDocument : node; 
    576   var nodesSnapshot = doc.evaluate(xpath, node, null, 
    577     XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
     565  var nodesSnapshot = (node.ownerDocument || node). 
     566    evaluate(xpath, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
    578567  var data = [] 
    579   for (var i = 0, l = nodesSnapshot.snapshotLength; i < l; ) { 
    580     data.push(nodesSnapshot.snapshotItem(i++)); 
    581   } 
     568  for (var i = 0, l = nodesSnapshot.snapshotLength; i < l; 
     569    data.push(nodesSnapshot.snapshotItem(i++))); 
    582570  return data.length > 0 ? data : null; 
    583571} 
     
    585573function getFirstElementByXPath(xpath, node) { 
    586574  var node = node || document; 
    587   var doc = node.ownerDocument ? node.ownerDocument : node; 
    588   var result = doc.evaluate(xpath, node, null, 
    589     XPathResult.FIRST_ORDERED_NODE_TYPE, null); 
     575  var result = (node.ownerDocument || node). 
     576    evaluate(xpath, node, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null); 
    590577  return result.singleNodeValue ? result.singleNodeValue : null; 
    591578} 
     
    618605} 
    619606 
    620 } 
     607})(unsafeWindow || this);