开发者

Chrome Extension URL Add 1

开发者 https://www.devze.com 2023-03-11 06:11 出处:网络
Well I\'m still learning about developing Chrome extensions, and been working on making small simple, just dumb extensions, and I asked a question yesterday which is pretty similar to today\'s questio

Well I'm still learning about developing Chrome extensions, and been working on making small simple, just dumb extensions, and I asked a question yesterday which is pretty similar to today's question.

So I'm using YouTube to understand/figure this out, and well I'm stuck.

What I'm trying to do is have the extension go开发者_如何学JAVA to http://www.youtube.com/results?search_query=1 and then refresh adding 1 on top of the additional 1 making it 2, then 3, and so on.

The code's below, and I guess you get the idea now of what I'd like help on.

var timer = setInterval(function() {
    chrome.tabs.getSelected(null, function(tab) {
        chrome.tabs.update(tab.id, {url: "http://www.youtube.com/results?search_query="+1});
    });
}, 5000);

// Stop
chrome.browserAction.onClicked.addListener(function(){
    clearInterval(timer);
});


Something like this?

var counter = 1;

var timer = setInterval(function() {
    chrome.tabs.getSelected(null, function(tab) {
        chrome.tabs.update(tab.id, {url: "http://www.youtube.com/results?search_query="+counter});
        counter++;
    });
}, 5000);
0

精彩评论

暂无评论...
验证码 换一张
取 消