{ "prefbar:info": { "formatversion": 3 }, "prefbar:menu:enabled": { "items": [ "prefbar:button:userstylecheckbox" ] }, "prefbar:button:userstylecheckbox": { "type": "extcheck", "label": "UserStyle", "browserbtnupdatefor": "false", "setfunction": "if (!event.shiftKey) {\n goPrefBar.SetPref(\"extensions.prefbar.buttons.userstylecheckbox.value\", value);\n window.PrefBarUserStyleCheckboxUpdate(true);\n}\nelse\n window.PrefBarUserStyleCheckboxUpdate(true, \"edit\");", "getfunction": "value = goPrefBar.GetPref(\"extensions.prefbar.buttons.userstylecheckbox.value\", false);", "initfunction": "// PrefBar UserStyle checkbox\n// Copyright (C) Manuel Reimer (Manuel _dot_ Reimer _at_ gmx _dot_ de)\n// This program is free software; you can redistribute it and/or\n// modify it under the terms of the GNU General Public License\n// version 3 as published by the Free Software Foundation\n\n// This function syncs pref value with load status of our stylesheet\n// We place this to the global \"window\" object as we also call it from set-function\nwindow.PrefBarUserStyleCheckboxUpdate = function(aInteractive, aAction) {\n // Get path of CSS file\n var dirService = Components.classes[\"@mozilla.org/file/directory_service;1\"]\n .getService(Components.interfaces.nsIProperties);\n var cssfile = dirService.get(\"ProfD\", Components.interfaces.nsIFile);\n cssfile.append(\"chrome\");\n cssfile.append(\"userstyle.css\");\n if (!cssfile.exists()) {\n if (aInteractive) goPrefBar.msgAlert(window, \"Stylesheet '\" + cssfile.path + \"' not found!\");\n return false;\n }\n\n // Open editor, if requested\n if (aAction == \"edit\") {\n var pref = \"extensions.prefbar.buttons.userstylecheckbox.editor\";\n var editor = goPrefBar.GetPref(pref);\n if (!editor)\n goPrefBar.msgAlert(window, \"You have to save the path to your editor to the following pref first: \" + pref);\n else\n setTimeout(function() {\n goPrefBar.RunApplication(editor, [cssfile.path]);\n }, 1000);\n return false;\n }\n\n // Convert path to file URI\n var fileHandler = Components.classes[\"@mozilla.org/network/protocol;1?name=file\"]\n .getService(Components.interfaces.nsIFileProtocolHandler);\n var cssuri = fileHandler.newFileURI(cssfile);\n\n // Load or unload stylesheet based on pref value\n var sss = Components.classes[\"@mozilla.org/content/style-sheet-service;1\"]\n .getService(Components.interfaces.nsIStyleSheetService);\n var status = goPrefBar.GetPref(\"extensions.prefbar.buttons.userstylecheckbox.value\");\n if (status && !sss.sheetRegistered(cssuri, sss.USER_SHEET))\n sss.loadAndRegisterSheet(cssuri, sss.USER_SHEET);\n else if (!status && sss.sheetRegistered(cssuri, sss.USER_SHEET))\n sss.unregisterSheet(cssuri, sss.USER_SHEET);\n\n return true;\n}\nwindow.PrefBarUserStyleCheckboxUpdate();" } }