我想插入一個按鈕的頁面谷歌日曆,但它不工作..Chrome擴展如何插入按鈕的頁面谷歌日曆
的manifest.json
{
"name": " Demo ",
"description": " demo ",
"version": "1.0",
"background": {
"scripts": ["background.js"]
},
"content_scripts": [{"matches": ["https://www.google.com/calendar/*"],
"js": ["demo.js"]}
],
"permissions": [
"tabs", "http://*/*", "https://*/*",
"activeTab"
],
"browser_action": {
"default_icon": "icon.png"
},
"icons" : {
"128" : "icon.png"
},
"manifest_version": 2
}
和content_scripts(demo.js):
document.addEventListener('DOMContentLoaded', function() {
var buttonOnSite = document.getElementById(":10.calendar-row"),
parent = buttonOnSite.parentElement,
next = buttonOnSite.nextSibling,
button = document.createElement("button"),
text = document.createTextNode("test");
button.appendChild(text);
if (next) parent.insertBefore(button, next);
else parent.appendChild(button);
});
然後我打開谷歌日曆......我找不到我的按鈕.. :10.calendar-row
是年曆的一個元素的ID ...
如何將一個按鈕插入到Google日曆頁面中,謝謝!
我有第二個問題,我無法調試,調試的按鈕是灰色的....爲什麼?
不調試彈出窗口,你沒有一個。調試內容腳本。請閱讀官方擴展開發指南,其中解釋了兩者。 –
謝謝你對第二問題的回答,我現在知道如何調試,你能幫我解答第一個問題嗎?如何在pas日曆中插入一個按鈕?非常感謝你 ! – user2262304