为Google表单创建Bookmarklet

时间:2016-12-03 09:25:16

标签: javascript bookmarklet google-form

我正在尝试为Google表单创建一个bookmarklet。

表格看起来如下:

https://docs.google.com/forms/d/e/1FAIpQLSc6Z725BQQ_GtDN-Gbwy0_W2ZqUt8RC3OeIQ37YExPS5igxPA/viewform

我尝试使用的书签是:

javascript: (function() {
    f = "https://docs.google.com/forms/d/1dqV7o4T1b5tjRI7KwSq8AhN2TSDK9EyIPb6Lj03blPA/viewform&entry_2=" + encodeURIComponent(window.location.href) + "&entry_1=" + encodeURIComponent(document.title);
    a = function() {
        if (!window.open(f, "mightchange", "location=yes,links=no,scrollbars=no,toolbar=no,width=450,height=650")) {
            location.href = f
        }
    };
    if (/Firefox/.test(navigator.userAgent)) {
        setTimeout(a, 0)
    } else {
        a()
    }
})();

当我按下书签时,我得到:

enter image description here

有什么建议我做错了吗?

提前谢谢!

1 个答案:

答案 0 :(得分:0)

你需要把它变成书签让我们使用:mrcoles.com

我也为你做了:

javascript:(function()%7Bjavascript%3A%20(function()%20%7Bf%20%3D%20%22https%3A%2F%2Fdocs.google.com%2Fforms%2Fd%2F1dqV7o4T1b5tjRI7KwSq8AhN2TSDK9EyIPb6Lj03blPA%2Fviewform%26entry_2%3D%22%20%2B%20encodeURIComponent(window.location.href)%20%2B%20%22%26entry_1%3D%22%20%2B%20encodeURIComponent(document.title)%3Ba%20%3D%20function()%20%7Bif%20(!window.open(f%2C%20%22mightchange%22%2C%20%22location%3Dyes%2Clinks%3Dno%2Cscrollbars%3Dno%2Ctoolbar%3Dno%2Cwidth%3D450%2Cheight%3D650%22))%20%7Blocation.href%20%3D%20f%7D%7D%3Bif%20(%2FFirefox%2F.test(navigator.userAgent))%20%7BsetTimeout(a%2C%200)%7D%20else%20%7Ba()%7D%7D)()%7D)()

确保您直接使用书签