我目前正在尝试编写自己的tampermonkey脚本,将事件的描述插入到Google日历中的弹出窗口中。 (编辑:点击时显示特定事件详情的弹出窗口)
不幸的是,谷歌日历内部的JS库隐藏了实际的请求/链接(所以我不知道实际执行了什么POST / GET请求或者它是如何生成的 - 它只是" javascript:void(0 )"。)
因此,我提出了三种不同的解决方案(每个问题都有一个问题):
感谢您的回答/帮助!
修改
我已经可以访问窗口的JS上下文(使用@grant unsafeWindow),但如果我能在上下文中找到事件的ID(直到现在都找不到它)我仍然会必须手动调用Google Calendar API。我想知道是否有更简单的方法来查找当前显示事件的描述(在当前事件弹出窗口中)。
我当前的代码如下所示(我要阅读说明的部分标有TODO):
// ==UserScript==
// @name EnhanceGCal
// @version 0.1
// @description Script to enhance the Google Calendar popup view
// @license Apache License 2.0
// @match https://www.google.com/calendar/*
// @grant unsafeWindow
// @require http://code.jquery.com/jquery-latest.js
// @require https://apis.google.com/js/client.js?onload=checkAuth
// ==/UserScript==
console.log('Started....')
// check if the bubble is available
if (!$('.bubblecontent').length) { console.log('Nothing found...'); return; }
// Try enhance the popup everytime it is created
$('.bubblecontent').bind("DOMSubtreeModified", function() {
var table, tbody, tr, td1, td2;
table = document.getElementsByClassName('eb-data')[0];
if (!table) { return; }
tbody = table.childNodes[0];
if (!tbody) { return; }
if (window.currentlyEditing) { return; }
window.currentlyEditing = true;
// add a new table row for the description
if (!$('#enhanceGCalDescriptionRow').length) {
tr = document.createElement('tr');
tr.id = 'enhanceGCalDescriptionRow';
td1 = document.createElement('td');
td1.innerHTML="<b>Description</b>";
td2 = document.createElement('td');
td2.innerHTML="Description text";
td2.id = 'enhanceGCalDescriptionText';
tr.appendChild(td1);
tr.appendChild(td2);
tbody.appendChild(tr);
}
// TODO read the description of the current event and set it in the new table column
$('#enhanceGCalDescriptionText').text('Enter description of the event in the popup here...');
window.currentlyEditing = false;
});