Chrome Extension 開發遇坑紀錄
還在開發 本篇算是小記 在開發完成前會陸續更新
popup 調用 chrome.extension.getBackgroundPage,
如果 background 是 inactive,會回傳 undefined,調用前先使用 Message call 喚醒。
Ajax 只能在 background page 發出 (popup 會出錯)
可以使用 chrome.extension.getBackgroundPage 將 popup 的 jquery selector ($) 傳到後端用。
不過注意其他 function call 的 context,比如在 background 寫的 alert,會是後端的 alert。
callback 使用兩種 lambda,結果會一樣嗎?
$('#id').click(()=>alert(this));
$('#id').click(function(){ alert(this); } );
JS non-pure 的坑 -- 小心在 for loop 中使用 lambda
a = []
for(i of [1,2,3]) a.push(()=> console.log(i))
a.map((f) => f())
// 3 3 3
一開始想說用 local var 解掉
a = []
for(i of [1,2,3]){var k=i; a.push(()=> console.log(k)) }
a.map((f) => f())
結果沒用,還是得用 IIFE 解掉
a = []
for(i of [1,2,3])
a.push(((k)=>
()=>console.log(k))(i))
a.map((f) => f())
UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
popup 調用 chrome.extension.getBackgroundPage,
如果 background 是 inactive,會回傳 undefined,調用前先使用 Message call 喚醒。
Ajax 只能在 background page 發出 (popup 會出錯)
可以使用 chrome.extension.getBackgroundPage 將 popup 的 jquery selector ($) 傳到後端用。
不過注意其他 function call 的 context,比如在 background 寫的 alert,會是後端的 alert。
callback 使用兩種 lambda,結果會一樣嗎?
$('#id').click(()=>alert(this));
$('#id').click(function(){ alert(this); } );
JS non-pure 的坑 -- 小心在 for loop 中使用 lambda
a = []
for(i of [1,2,3]) a.push(()=> console.log(i))
a.map((f) => f())
// 3 3 3
一開始想說用 local var 解掉
a = []
for(i of [1,2,3]){var k=i; a.push(()=> console.log(k)) }
a.map((f) => f())
結果沒用,還是得用 IIFE 解掉
a = []
for(i of [1,2,3])
a.push(((k)=>
()=>console.log(k))(i))
a.map((f) => f())
UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="/background/index.js" charset="utf-8"></script>
--- web store
a bot extension for drrr.com, so need drrr.com content_script, and get music link need music.163 tingapi.ting, fetch line sticker as feature but not impl yet
--- web store
a bot extension for drrr.com, so need drrr.com content_script, and get music link need music.163 tingapi.ting, fetch line sticker as feature but not impl yet
Your Product violates the “Use of Permissions” section of the policy, which requires that you:
- Request access to the narrowest permissions necessary to implement your Product’s features or services. If more than one permission could be used to implement a feature, you must request those with the least access to data or functionality.
- Don't attempt to "future proof" your Product by requesting a permission that might benefit services or features that have not yet been implemented.
- To reinstate your Product, please ensure that your Product requests and uses only those permissions that are necessary to deliver the currently stated product’s features.
- Your item has a blank description field, or missing icons or screenshots, and appears to be suspicious
意思是說還沒實作的功能不能要權限。
留言
張貼留言