2009-11-14 3 views
2

일부 애드온은 광산과 호환되지 않으므로 그 존재를 감지하고 사용자에게 알리는 방법.Firefox Addon 개발 : 호환되지 않는 애드온 검색 중?

function isExtEnabled(){ 

    if(!Application.extensions.has('EXTENSION_ID_HERE')) { 

     return false; 
    } 
    return true; 
    } 
:

덕분에 여기

+0

당신은 분명히 할 수 있습니까? 즉, 이미 설치된 애드온과 호환되지 않는 애드온을 어떻게 알 수 있습니까? – benc

+1

특정 애드온이 설치되어 있고 활성화되어 있는지 여부를 확인하고 싶습니다. 예를 들어 나는 플래시 블록이 설치되어 있는지 여부를보고 싶다. – iTech

답변

5

확인이 여기있어이 작업이 어떻게 애드 블록 플러그인 설정을

을 수정 악 NOSCRIPT-1.9.2.xpi에서 예입니다
0

function MRD(ns) { 
    this.enabled = ns.getPref("mrd", true); 
    if (!this.enabled) return; 

    var c = CC[this.id]; 
    if (c) { 
    this.ns = ns; 
    this.c = c.createInstance().wrappedJSObject; 
    this._w._mrd = this; 
    var eh = this.c["elemhide"]; 
    eh.watch("url", this._w); 
    eh.apply(); 
    ns.mrd = this; 
    ns.initContentPolicy(); 
    } else this.enabled = false; 
} 
MRD.prototype = { 
    id: "@mozilla.org/adblockplus;1", 
    _nobind: "{-moz-binding: none !important}", 
    _ms: null, 
    _w: function(p, o, n) { 
    if (!n) return n; 
    var mrd = arguments.callee._mrd; 
    var u = decodeURIComponent(n.spec); 

    var mm = u.match(/@-moz-document\s+domain[^\)]*?(?:(?:noscript|flashgot|hackademix)\.net|informaction\.com|googlesyndication\.com)[^\}]*\}/g); 
    if (mm) { 
     var ns = mrd.ns; 
     mrd._ms = mm.join('').replace(/(\{[^\{\}]*)\{[^\}]*/g, '$1' + mrd._nobind); 
    } 

    /* 
    var uu = n.spec.split(','); 
    uu[1] = encodeURIComponent(decodeURIComponent(uu[1]).replace(/@-moz-document\s+domain[^\)]*?(?:(?:noscript|flashgot|hackademix)\.net|informaction\.com|googlesyndication\.com)[^\}]*\}/g, '')); 
    n.spec = uu.join(','); 
    */ 
    mrd.ns.delayExec(function() { mrd.apply(); }, 0); 
    return n; 
    }, 
    _dd: function(a, s) { 
    return "@-moz-document domain(" + a.join("),domain(") + "){" + s + "} "; 
    }, 

    get _def() { 
    delete this.__proto__._def; 
    return this.__proto__._def = this.ns.prefService.getDefaultBranch(this.ns.prefs.root).getCharPref("default"); 
    }, 
    get _wl() { 
    delete this.__proto__._wl; 
    return this.__proto__._wl = this._def.match(/\w+[^r].\.n\w+|in\w+on\.c\w+/g).concat(this.ns.getPref("xblHack", "").split(/\s+/)); 
    }, 
    get _wlrx() { 
    delete this.__proto__._wlrx; 
    return this.__proto__._wlrx = new RegExp("^(?:[\\w\\-\\.]*\\.)?(?:" + this._wl.join("|").replace(/\./g, "\\.").concat(")$")); 
    }, 
    get _es() { 
    delete this.__proto__._es; 
    try { 
     var ss = [], lastS = ''; 
     for(var j = 0; j < 5; j++) { 
     ss.push(lastS += " #k" + j); 
     } 
     es = this._dd(this._wl, ss.join(' *,') + ' *' + this._nobind) + 
      this._dd(this._def.match(/\w+[^r].\.n\w+|\w+on\.c\w+/g), "#a\u0064s, #\u0061ds .ad" + this._nobind); 
    } catch (e) { 
     if (this.ns.consoleDump) this.ns.dump("MRD ES Error: " + e); 
    } 
    return this.__proto__._es = es; 
    }, 

    apply: function() { 
    var ns = this.ns; 
    for each(var s in [this._es, this._ms]){ 
     if (s) { 
     ns.updateStyleSheet(s, false); 
     ns.updateStyleSheet(s, true); 
     } 
    } 
    }, 

    attach: function() { 
    if (!this.enabled) return false; 
    try { 
     var p = this.c.policy; 
     var ns = this.ns; 
     var wlrx = this._wlrx; 
     if (!wlrx) return false; 
     ns._mrd_shouldLoad = ns.shouldLoad; 
     ns.shouldLoad = function(ct, cl, ro, ctx, mm, internal) { 
     if (!internal) try { 
      var w = ctx && (ctx.defaultView || ctx.ownerDocument && ctx.ownerDocument.defaultView || ctx); 
      if (w) { 
      l = w.top.location; 
      if (!(/^https?/.test(l.protocol) && wlrx.test(l.hostname))) { 
       var res = p.shouldLoad(ct, cl, ro, ctx, mm, internal); 
       if (res != CP_OK) return res; 
      } 
      } 
     } catch(e) { 
      if (ns.consoleDump) ns.dump(e); 
     } 
     return ns._mrd_shouldLoad(ct, cl, ro, ctx, mm, internal); 
     }; 
    } catch(e) { 
     if (this.ns.consoleDump) this.ns.dump("MRD Attach Error: " + e); 
     return false; 
    } 
    return true; 
    } 
}