English 中文(简体)
用于更新网页的 Chrome延
原标题:Chrome extension used to refresh pages

我正试图开发一个“ Chrome号”,通过每5分钟复播一次,从一个足球新闻网站(显然,该网页在任何表格中都不会开放)上播放最后3份新闻。 我的ide子将装上一栏,一页装满后,即可进入DOM网页,只抽取新闻。 我以多种方式尝试使用<>strong>、和load功能,试图遵循这一解决办法:here。 但总是得到警告。 我的问题是:我是否能够这样做,同时又不担心交叉安全问题? 是否有任何简单的例子可以使用?

最佳回答

Here s how you could do it using JQuery (please keep in mind I dont know JQuery, just saw this approach somewhere and thought it might work for you).
I put this in a popup and it worked....

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script>

function renderNews(newsList){
      $( #news ).html(  );
      $(newsList).each(function(i,item){
         var link = document.createElement( a );
         $(link).attr( href ,item.link);
         $(link).html(item.description);
         $(link).click(function(){
            chrome.tabs.create({url:$(this).attr( href )});
         });

         var linksDate = document.createElement( span );
         //$(linksDate).text(item.date);
         $(linksDate).text(item.day +  -  + item.month +     + item.hour +  :  + item.minute+  -  );

         var listItem = document.createElement( li );
         $(listItem).append(linksDate).append(link);

         $("#news").append(listItem);
       });
}


  function getNews() {
   $.get("http://www.milannews.it/?action=search&section=32", null,  function(data, textStatus)
    {

        if(data) {
        var news=$(data).find(".list").find( li ).slice(0,3) ;
        $("#status").text(  );

      var newsList=[];
      $(news).each(function(i, item){
       var newsItem={};
       newsItem.description=$(item).find( a ).html();
       newsItem.link= http://www.milannews.it/ +$(item).find( a ).attr( href );
       newsItem.date=$(item).find( span ).first().text();
       newsItem.day=newsItem.date.split(   )[0].split( . )[0];
       newsItem.month=newsItem.date.split(   )[0].split( . )[1];
       newsItem.hour=newsItem.date.split(   )[1].split( : )[0];
       newsItem.minute=newsItem.date.split(   )[1].split( : )[1];
       newsList[i]=newsItem;
      });
      renderNews(newsList);
      localStorage.setItem( oldNews ,JSON.stringify(newsList));
        }
    });
  }

  function onPageLoad(){
   if (localStorage["oldNews"]!=null) renderNews(JSON.parse(localStorage["oldNews"]));
   getNews();
  }
</script>
</head>
<body onload="onPageLoad();" style="width: 700px">
<ul id="news"></ul>
<div id="status">Checking for new news...</div>
</body>
</html>

And dont forget to put the urls your getting with the xhr stuff in the permissions part of your manifest....
http://code.google.com/chrome/extensions/xhr.html

问题回答

使用xhr装上页,并使用jQuery或regex对你正在研究的数据进行硬通量。

铭记目的地可能不想以如此自动化的方式进入其网站。 尊重他们的场址和资源。





相关问题
Redirect to cache URL in Chrome browser

self.location = cache: + self.location I want to redirect from "[URL]" to "cache:[URL]". I just want this code to work in Chrome browser.

我如何更新/重载 Chrome延?

I m在4号 Chrome(目前为4.0.249.0)中开发一个延伸点,显示用户在地位酒吧中的形象。 Ive设计了一个供用户使用的备选办法网页......

Setting Opacity in CSS For Chrome

I ve tried the following: (this is actually for fancybox, as the overlay does not show in chrome/safari: $("#fancy_overlay").css({<br /> background-color : opts....

Chrome Blocking Javascript, Google Wave, Google Gadgets

Project: Developing a gadget template for Google Wave which will allow my Flash movies to interact with the Wave api. I had to adapt the existing Flex application so that it would work with ...

image height using jquery in chrome problem

$( img ).height() returns 0 in chrome, but it returns the actual height in IE and firefox. Whats the actual method to get the height of the image in chrome?

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Table cells bad rendering with Google Chrome/Webkit

On the following code, COL1A and COL3A are not 50% height with Chrome or Webkit. It works fine with IE7 and Firefox. <table border="1"> <tr> <td height="100%">COL 1A</td>...

热门标签