gpt4 book ai didi

javascript - gmail javascript 书签

转载 作者:行者123 更新时间:2023-11-30 13:43:46 25 4
gpt4 key购买 nike

如果我在新标签页 (FF3) 中加载它,它就会工作。如果我将它加载到当前选项卡中,它只会打印 url。

我认为这实际上是将它加载到现有的 gmail 选项卡中的问题。所以说,制作小书签,单击一次,然后再次单击。这似乎是重现问题的方法。

知道是什么原因造成的吗?我可以想到一些解决方法,但我很好奇它是如何工作的。

javascript:var%20t=new%20Date(),y=t.getFullYear(),m=t.getMonth()+1,d=t.getDate();document.location.href="http://mail.google.com/mail/#search/is%3Aunread+after%3A"+y+"-"+m+"-"+d

/* same code split up for readability */
javascript:
var t = new Date(),
y = t.getFullYear(),
m = t.getMonth()+1,
/* d = t.getDay(); I actually have this correct above, but not here.. oops */
d = t.getDate();
document.location.href="http://mail.google.com/mail/#search/is%3Aunread+after%3A"+y+"-"+m+"-"+d;

有什么帮助吗?

谢谢:)

更新:

当我从 this 中删除多余的空格时answer 并将必要的空格转换为“%20”(url 编码),它什么都不做:

 /* this works. I was missing the final ")" altCognito wrote */
javascript:void((function(){var%20t=%20new%20Date(),y=t.getFullYear(),m=t.getMonth()+1,d=t.getDate();window.location.href="http://mail.google.com/mail/#search/is%3Aunread+after%3A"+y+"-"+m+"-"+d;})())

我还尝试了一些分号调整和其他一般语法检查,但我不确定我在寻找什么。它既不能用作小书签,也不能直接粘贴到地址栏中(无论如何对我来说)。

最佳答案

你想要的是这样的:

javascript:void(
(function() {
var t = new Date(),
y = t.getFullYear(),
m = t.getMonth()+1,
d = t.getDate();
window.location.href="http://mail.google.com/mail/#search/is%3Aunread+after%3A"+y+"-"+m+"-"+d;
})()
)

关键是 void((function() {... 你的东西在这里 ... })())

请注意,您还想使用 getDate() 而不是 getDay,因为 getDay 会返回星期几!

关于javascript - gmail javascript 书签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/728079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com