home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 March / PCpro_2006_03.ISO / files / freeware / greasemonkey-0.6.4-fx.xpi / chrome / chromeFiles / content / miscapis.js < prev    next >
Encoding:
Text File  |  2005-11-30  |  1.3 KB  |  46 lines

  1.  
  2.  
  3. function GM_ScriptStorage(script) {
  4.   this.prefMan = new GM_PrefManager(["scriptvals.",
  5.                                      script.namespace,
  6.                                      "/",
  7.                                      script.name,
  8.                                      "."].join(""));
  9. }
  10.  
  11. GM_ScriptStorage.prototype.setValue = function(name, val) {
  12.   this.prefMan.setValue(name, val);
  13. }
  14.  
  15. GM_ScriptStorage.prototype.getValue = function(name, defVal) {
  16.   return this.prefMan.getValue(name, defVal);
  17. }
  18.  
  19.  
  20. function GM_ScriptLogger(script) {
  21.   var namespace = script.namespace;
  22.   
  23.   if (namespace.substring(namespace.length - 1) != "/") {
  24.     namespace += "/";
  25.   }
  26.   
  27.   this.prefix = [namespace, script.name, ": "].join("");
  28. }
  29.  
  30. GM_ScriptLogger.prototype.log = function(message) {
  31.   GM_log(this.prefix + message, true);
  32. }
  33.  
  34.  
  35. // Based on Mark Pilgrim's GM_addGlobalStyle from 
  36. // http://diveintogreasemonkey.org/patterns/add-css.html. Used by permission
  37. // under GPL: http://diveintogreasemonkey.org/license/gpl.html
  38. function GM_addStyle(doc, css) {
  39.   var head, style;
  40.   head = doc.getElementsByTagName('head')[0];
  41.   if (!head) { return; }
  42.   style = doc.createElement('style');
  43.   style.type = 'text/css';
  44.   style.innerHTML = css;
  45.   head.appendChild(style);
  46. }