2012-06-01 36 views

回答

1

不,你不能。使用您在單擊書籤時查看的網頁的特權運行Bookmarklets,並且網頁無法更改用戶首選項...

0

您不能因上下文而使書籤欄和菜單處於,但也許你想看看'自定義按鈕:'https://addons.mozilla.org/en-US/firefox/addon/custom-buttons/

它運行在'鉻'上下文作爲一個XUL覆蓋,因此可以訪問about:config設置。

下面是一個例子腳本我作出改變「回退字符編碼」時在HTML頭部中指定爲「SHIFT_JIS」的日本沒有編碼:

(主代碼標籤)

/* toggle between SHIFT_JIS and 'default for locale' character encoding. */ 

var prefsManager = Components.classes["@mozilla.org/preferences-service;1"] 
        .getService(Components.interfaces.nsIPrefBranch); 
var defaultCharEncoding = prefsManager.getCharPref("intl.charset.fallback.override"); 

if (defaultCharEncoding !== "Shift_JIS") { 
/* change button icon to the hiragana 'あ'. Originally I had a base64 encoded PNG here. */ 
    document.querySelector('toolbarbutton#custombuttons-button1.toolbarbutton-1.chromeclass-toolbar-additional').image="file:///path/to/icon/a-jp1.svg"; 
    prefsManager.setCharPref("intl.charset.fallback.override","Shift_JIS"); 
} else { 
/* can't use clearUserPref() on the default branch */ 
    prefs = prefsManager.getBranch("intl.charset.fallback."); 
/* set button icon to the letter 'a'. Originally I had a base64 encoded PNG here. */ 
    document.querySelector('toolbarbutton#custombuttons-button1.toolbarbutton-1.chromeclass-toolbar-additional').image="file:///path/to/icon/a-en1.svg"; 
/* reset the 'intl.charset.fallback.override' entry to it's default (blank) */ 
    prefs.clearUserPref("override"); 
} 

請注意,我爲seamonkey做了這個,因此查詢選擇器可能會有所不同。這裏的一切都絕對適用於Firefox。該插件與seamonkey,firefox和thunderbird一起使用。