popup.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. $(function(){
  2. $('#spendAmount').click(function(){
  3. // chrome.tabs.getSelected(null, function (tab) {//获取当前tab
  4. // //向tab发送请求
  5. // window.alert(tab.id)
  6. // chrome.runtime.sendMessage('你好');
  7. // });
  8. chrome.tabs.getSelected(null, function (tabs) {
  9. // window.alert(tabs.id)
  10. console.log(tabs.id)
  11. chrome.tabs.sendMessage(tabs.id,{method:'getSelection'}, function (response) {
  12. window.alert(JSON.stringify(response))
  13. console.log(response, 'content.js回传过来的信息');
  14. });
  15. });
  16. // var notifications = {
  17. // type:'basic',
  18. // iconUrl:'icon48.png',
  19. // title:'123',
  20. // message:'1234'
  21. // }
  22. // chrome.notifications.create('limitNotif',notifications)
  23. })
  24. // chrome.storage.get('total',function(budget){
  25. // $('#total').text(budget.total);
  26. // })
  27. // $('#spendAmount').click(function(){
  28. // chrome.storage.sync.get('total',function(budget){//浏览器存储
  29. // var newTotal = 0;
  30. // if(budget.total){
  31. // newTotal += perseInt(budget.total)
  32. // }
  33. // var amount = $('#amount').val()
  34. // if(amount){
  35. // newTotal += parseInt(amount)
  36. // }
  37. // chrome.storage.sync.set({
  38. // 'total': newTotal
  39. // });
  40. // $('#total').text(newTotal);
  41. // $('#amount').val("");
  42. // });
  43. // });
  44. // $('#name').keyup(function(){
  45. // $('#greet').text('Hello ' + $('#name').val())
  46. // })
  47. })