我在 wolframalpha.com 中输入了很多查询。当我返回该网站并尝试输入我以前输入过的内容时,什么也没有发生。在其他网站(如 superuser.com)上,如果我在搜索框中输入内容,Firefox 会记住我以前的查询并向我推荐。为什么这在 Alpha 上不起作用?我可以使用 greyonkey 脚本使其工作吗?
<form method="get" action="/input/" accept-charset="UTF-8" autocomplete="off">
<div id="input-background">
<input name="i" id="i" maxlength="200" autocapitalize="off" type="text">
<a id="iClear" style="display: none;"></a>
<label class="hidden" for="equal">Calculate</label>
<input id="equal" title="compute" value="Submit" type="submit">
<div id="howTo"></div>
</div>
</form>
答案1
Wolfram Alpha 的搜索框具有autocomplete="off"
属性,因此浏览器会尊重该属性,并且输入框不会填写。我找不到任何 greymonkey 脚本来更改此行为
有替代, 然而。请记住 - 这将启用所有内容的自动完成功能。
1. Locate Firefox’s installation folder. Normally that’s C:\Program Files\Mozilla Firefox
2. Navigate to the components folder.
3. Open nsLoginManager.js in an editor. As Notepad won’t do really, do this instead [if you've a proper editor, just go to step 4]:
3a) Select Start | Run
3b) Enter cmd <enter or Ok>
3c) type cd C:\Program Files\Mozilla Firefox\components <enter>
3d) type edit nsLoginManager.js <enter>
3e) Go to step 4.
4. Find this:
/*
* _isAutoCompleteDisabled
*
* Returns true if the page requests autocomplete be disabled for the
* specified form input.
*/
_isAutocompleteDisabled : function (element) {
if (element && element.hasAttribute("autocomplete") &&
element.getAttribute("autocomplete").toLowerCase() == "off")
return true;
return false;
},
5. Change it to this:
/*
* _isAutoCompleteDisabled
*
* Returns true if the page requests autocomplete be disabled for the
* specified form input.
*/
_isAutocompleteDisabled : function (element) {
return false;
},
6. Save the file [if you're following the 3x) steps above, select File | Exit, and when asked if you want to save the edited file, answer Yes. To close the command prompt, enter exit <enter>].
Note that you might first have to change the file’s security permissions to do this [you DO if the save fails]. E.g., in Vista I had to A) right-click on the file [e.g., in Explorer] B) select Properties | Security. B) select Edit. C) select your username, D) change the persmissions to include Write access.
And you’re done – either start, or close/re-start Firefox!
答案2
下面说明了如何使用 Greasemonkey 为特定站点启用它:
// ==UserScript==
// @name Alpha autocomplete on
// @namespace
// @description Enables browser form history for Wolfram Alpha
// @include *wolframalpha.com*
// ==/UserScript==
document.forms[0].setAttribute("autocomplete", "on")