这是 Sjoerd 解决方案的一种变体。
主要区别在于使用停靠单元格而不是弹出对话框。该单元格有一个指向新帖子的链接,以及一个按钮,可以将停靠的单元格清除到之前的状态。
另一个区别是使用问题 ID 而不是标题来确定新帖子。我知道标题有时会被编辑,所以在这种情况下会触发新帖子。
storedTitle = "";
storedID = 0;
mySOWatchTask =
CreateScheduledTask[{lastTitle,
lastID} = {"title",
"question_id"} /. ("questions" /.
Import["http://api.stackoverflow.com/1.1/questions?key= \
QEpjCjsXYE6s_kZEkFr4Lw&page=1&pagesize=1&sort=creation&\
tagged= mathematica", "JSON"])[[1]];
If[lastID != storedID,
storedTitle = lastTitle;
storedID = lastID;
SetOptions[$FrontEndSession,
DockedCells ->
Cell[BoxData[
ToBoxes[Style[
With[{dock = Options[$FrontEndSession, DockedCells]},
Grid[{{Button[Style["\[CircleTimes]", 16],
SetOptions[$FrontEndSession, dock],
Appearance -> None], "New StackOverflow question: ",
Hyperlink[lastTitle,
"http://stackoverflow.com/questions/" <>
ToString[lastID]]}},
Alignment -> {{Left, Left, Left}},
ItemSize -> {{2, 14, Scaled[0.7]}}]],
FontFamily -> "Times"]]], "DockedCell",
Background -> Orange]]; EmitSound[Sound[SoundNote[]]]];, 60];