我期待創建一個Chrome擴展程序,該程序只是在創建新事件時添加一些功能。我想在「創建事件」視圖中插入一個額外的字段,該視圖將接受要存儲的新元數據,即:項目名稱,客戶端名稱等。Chrome擴展程序 - 修改Google日曆事件UI以通過輸入字段接受擴展屬性
到目前爲止,我設法創建了擴展,設置彈出窗口視圖,插入一些新的HTML到通過contentscripts.js核心日曆視圖,但我無法弄清楚如下:
1)新的文本輸入字段添加到事件創建視圖從
2)保存文本根據谷歌API(https://developers.google.com/google-apps/calendar/extended-properties)以上字段作爲「擴展屬性」以供日後檢索
有沒有人有任何意見或建議想要完成這樣一項任務?
這裏是我的manifest.json文件:
{
"name": "DoviChrome",
"version": "0.1.1",
"manifest_version":2,
"description": "DoviChrome",
"background": {
"persistent": false,
"scripts": ["background.html"]
},
"icons": { "16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"browser_action": {
"default_icon": { // optional
"16": "icon2.png", // optional
"24": "icon2.png", // optional
"32": "icon2.png" // optional
},
"default_title": "DoviChrome", // optional; shown in tooltip
"default_popup": "popup.html" // optional
},
"permissions": [
"notifications",
"identity",
"storage",
"activeTab"
],
"content_scripts": [
{
// Change 'matches' attribute to load content
// script only in pages you want to.
"matches": ["*://calendar.google.com/calendar/render"],
"css": ["css/style.css"],
"js": ["js/lib/jquery-3.1.1.min.js", "js/lib/angular1.6.1.min.js", "contentscript.js"],
"run_at": "document_idle",
"all_frames": false
}
],
"web_accessible_resources": [ "img/*", "node_modules/*","*.png","https://www.parsecdn.com/js/parse-latest.js"],
}
...這是我用我contentscript.js什麼插入在主日曆其他一些功能視圖。
$(document).ready(function() {
console.log("contentscript.js loaded")
var iconURL = chrome.extension.getURL("icon.png");
console.log("Injecting UI...")
$("#calcontent #vr-nav").before("<div class='new-menu'>" +
"<div class='my-logo inline'><img src='" + iconURL + "'/></div>" +
"<div class='quick-report'>Create Timesheet</div>" +
"<div class='quick-settings'>Settings</div>" +
"</div>"
)
$('.quick-report').on("click",function(){
\t console.log("clicked reports")
})
$('div.quick-settings').on("click",function(){
\t console.log("Clicked settings")
})
});
您可能想嘗試使用[Google日曆事件小工具](https://developers.google.com/google-apps/calendar/gadgets/event/)。此功能使您可以將任何類型的內容添加到日曆中。您可以選擇使用iCalendar格式或Google Calendar API v3來創建日曆事件小工具。 – Teyam
你好,你完成了這個擴展? –
不,我還沒有。部分,但仍在尋找上述解決方案。你想要做同樣的事嗎? –