chrome.runtime.onInstalled.addListener(function(){chrome.declarativeContent.onPageChanged.removeRules(void 0,function(){chrome.declarativeContent.onPageChanged.addRules([{conditions:[new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.aliexpress.com",schemes:["https"]},css:["button[type='submit']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"s.1688.com",schemes:["https"]},css:["button[type='submit']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"detail.1688.com",schemes:["https"]},css:["div[id='mod-detail-title']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.amazon.com",schemes:["https"]},css:["input[id='add-to-cart-button']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.cdiscount.com",schemes:["https"]},css:["input[id='fpAddBsk']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.ebay.com",schemes:["https"]},css:["a[id='binBtn_btn']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.wish.com",schemes:["https"]},css:["a[id='binBtn_btn']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"www.tophatter.com",schemes:["https"]},css:["button[id='buy']"]}),new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"dash.5miles.com",schemes:["https"]},css:["button[id='buy']"]})],actions:[new chrome.declarativeContent.ShowPageAction]}])}),chrome.contextMenus.create({title:"\u7ACB\u5373\u521B\u5EFA\u4EA7\u54C1",contexts:["page"],id:"createproductimd"})});function showCreateProductPage(){chrome.storage.local.remove("product",function(){chrome.tabs.create({url:"ext/html/generateNewProduct.html"})})}chrome.contextMenus.onClicked.addListener(showCreateProductPage),chrome.webNavigation.onCompleted.addListener(function(a){console.log("navigation complete : "+JSON.stringify(a)),chrome.tabs.get(a.tabId,function(a){console.log("navigation complete : "+JSON.stringify(a))})},{url:[{urlMatches:"https://s.1688.com/*"},{urlMatches:"https://detail.1688.com/*"}]}),chrome.runtime.onMessage.addListener(function(a,b,c){console.log(b.tab?"from a content script:"+b.tab.url:"from the extension"),"createTabFlag"in a&&"productInfo"in a&&!0==a.createTabFlag?(chrome.storage.local.set({product:JSON.parse(a.productInfo)}),chrome.tabs.create({url:"ext/html/generateNewProduct.html",index:b.tab.index+1},function(){})):"createTabFlag"in a&&"oauthURL"in a&&chrome.tabs.create({url:a.oauthURL,index:b.tab.index+1},function(){console.log("prepare to send response"),c({createdFlag:!0})})});