小书签脚本太长,无法创建应用程序快捷方式
我想出了如何为 Google Analytics 创建一个书签,该书签打开后立即仅显示今天的统计数据。我想为此创建一个 Google Chrome 应用程序快捷方式,以便与我的其他 Google Apps 快捷方式并排,但第一个问题是它仅创建具有当前 url 的应用程序,该应用程序显示今天的信息,当然明天也会显示昨天的信息。我想我应该编辑快捷方式的目标,并用我拥有的 javascript 替换 url。第二个问题是脚本行太长。 Windows 的快捷方式目标路径只能容纳 290 个字符或类似的字符。 Chrome 的路径以及脚本已经过去了。
此时我有什么选择?我在网上搜索过,为我生命中的一小部分浪费了太多时间,但我想弄清楚。
我对编程很了解。我可以编辑 javascript,但不能真正编写它。我使用 YUI Compressor 尝试缩小它,但变化不大。我也尝试过使用 url 缩短器,但它们都添加了 http:// 前缀,这一切都搞砸了。我读到我可以指向快捷方式目标中的一个bat文件,但也不知道如何做到这一点...而且我认为有一种更简单的方法可以做到这一点,不需要任何小的黑客攻击,我想避免。
我可以轻松地在 Chrome 中为该网站添加书签,并用 javascript 替换 url,它工作得很好,这就是我目标的一半。但我真的很想将其作为 Windows 快捷方式,并以与其他应用程序完全相同的方式运行,因为它们会记住以前的窗口大小。
关于简单的解决方案有什么建议吗?
这是小书签的脚本 -
javascript:var d=new Date();if(d.getMonth()<10){var pad='0';};var t=''+d.getFullYear()+(pad+(d.getMonth()+1))+d.getDate();location.href='https://www.google.com/analytics/reporting/dashboard?id=HIDDENID&pdr='+t+'-'+t+'&cmp=average'
另外,这是从 Chrome 到不同但非常相似的应用程序快捷方式的路径 -
"C:\Documents and Settings\USERPROFILE\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --app=http://docs.google.com/a/MYGOOGLEAPPSDOMAIN/
I figured out how to create a bookmarklet for Google Analytics that opened to immediately show only today's stats. I wanted to make a Google Chrome application shortcut for this to go along side my other Google Apps shortcuts, but the first problem is that it only creates an application with the current url, which displays today's info and of course will display yesterday's info tomorrow. I figured I'd edit the target to the shortcut and replace the url with the javascript I had. The second problem is the line of script is too long. Window's shortcuts target paths can only hold 290 characters or something like that. The path to Chrome as well as the script went past that.
What are my options at this point? I've scoured the web and wasted way too much time for such a small piece of my life, but I'd like to figure it out.
I know jimmy-squat about programming. I can sort of edit javascript, but not really write it. I used the YUI Compressor to try and shrink it down, but it didn't change much. I also tried using a url shortener, but they all add the http:// prefix and that screwed it all up. I read I could point to a bat file in the shortcut target, but couldn't figure out how to do that either... plus I figured there was an easier way to do this that didn't require any minor hacking, which I'd like to avoid.
I was easily able to bookmark the site in Chrome and replace the url with the javascript and it works fine, and that was half my goal. But I really would like to have this as a Windows shortcut and behave in the exact same way the other apps work because they remember the previous window size.
Any suggestions on an easy solution?
Here's the bookmarklet's script -
javascript:var d=new Date();if(d.getMonth()<10){var pad='0';};var t=''+d.getFullYear()+(pad+(d.getMonth()+1))+d.getDate();location.href='https://www.google.com/analytics/reporting/dashboard?id=HIDDENID&pdr='+t+'-'+t+'&cmp=average'
Also here's the path to different but pretty similar application shortcut from Chrome -
"C:\Documents and Settings\USERPROFILE\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --app=http://docs.google.com/a/MYGOOGLEAPPSDOMAIN/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不创建一个包含以下内容的本地
.html
文件:然后您可以将其用作“快捷方式”。
%AppData% 也可以帮助您从快捷方式中获取更多字符。如果从命令行运行 chrome.exe 导致打开的窗口类型与双击 HTML 文件不同,您可能需要将 chrome.exe 指向 workaround.html
另外,手动压缩一些逻辑会导致在这个 268 个字符的高尔夫代码中,它可能适合你,也可能不适合你。
Why not create a local
.html
file containing this:Then you can just use that as your "shortcut".
The %AppData% may help you get a few more characters out of the shortcut as well. If running chrome.exe from the command line is resulting in a different type of window being opened than double clicking the HTML file, you may need to point chrome.exe at the workaround.html
Also, manually compressing some of your logic a bit resulted in this 268 character code golf which may or may not work for you.