找回密码
 加入傲游社区
跳转到指定楼层

[插件求助] 嫩不能做个 鼠标指针移到收藏文件夹自动打开下拉菜单

[复制链接]
baoyu2002 [初入江湖] 发表于 2016-1-24 18:05:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式  2364 1
火狐的
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <overlay id="ucjsPermission" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">


  3. <script type="application/x-javascript" xmlns="http://www.w3.org/1999/xhtml"><![CDATA[

  4. var autopopupxul = {
  5. runautopopup: function() {
  6.     var PopElt = null;    var DropElt = null;
  7.     var PopTimer = null;  var HideTimer = null;
  8.     var AlwaysPop = false;  var nDelay = 200;

  9.     function AutoPopup()
  10.     {
  11.         PopTimer = null;
  12.         if (DropElt) {
  13.             if (DropElt.localName!='dropmarker') {
  14.                 var v = null;
  15.                 try {
  16.                     v = DropElt.ownerDocument.
  17.                         getAnonymousNodes(DropElt);
  18.                 }catch(ex) {}
  19.                 if (v!=null && v.length!=0 && v[0].
  20.                     localName=='menupopup')
  21.                     PopElt = v[0];
  22.                 else
  23.                     PopElt = DropElt.childNodes[0];
  24.             }
  25.             else
  26.                 PopElt = DropElt;
  27.             try {
  28.                 PopElt.showPopup(PopElt.parentNode,
  29.                     -1, -1, 'popup', 'bottomleft',
  30.                             'topleft');
  31.             }catch(e) { PopElt = null; }
  32.         }
  33.     }

  34.     function HidePopup()
  35.     {
  36.         try {
  37.             if (PopElt.localName=='dropmarker')
  38.                 PopElt.parentNode.closePopup();
  39.             else
  40.                 PopElt.hidePopup();
  41.         }catch(e) {}
  42.         HideTimer = null; DropElt = null;
  43.         PopElt = null;
  44.     }

  45.     function MouseOver(e)
  46.     {
  47.         if (!AlwaysPop && !document.hasFocus())
  48.             return;

  49.         if (IsButton(e.target)) {
  50.             type = e.target.getAttribute('type');
  51.             if (type == 'menu-button') {
  52.                 if (e.originalTarget!=e.target)
  53.                     return;
  54.             }
  55.             else {
  56.                 if (type != 'menu') return;
  57.             }
  58.         }

  59.         if (HideTimer) {
  60.             window.clearTimeout(HideTimer);
  61.             HideTimer = null;
  62.         }
  63.         try {
  64.             if ('PopupAutoComplete'==e.target.id.
  65.                 substr(0,17))
  66.                 return;
  67.             for(var elt=e.target; elt!=null; elt=
  68.                 elt.parentNode) {
  69.                 if (elt.localName=='popup' || elt.
  70.                     localName=='menupopup')
  71.                     return;
  72.             }
  73.         }catch(ex) {}

  74.         if (PopElt) {
  75.             if (DropElt!=null && e.target==DropElt)
  76.                 return;
  77.             try {
  78.                 if (PopElt.localName != 'dropmarker'
  79.                     ) {
  80.                     for(var elt=e.target; elt!=null;
  81.                         elt=elt.parentNode) {
  82.                         if (elt == PopElt) return;
  83.                     }
  84.                 }
  85.             }catch(ex) {}
  86.             HidePopup();
  87.         }
  88.         DropElt = e.target;
  89.         PopTimer = setTimeout(AutoPopup, nDelay);
  90.     }

  91.     function MouseOut(e)
  92.     {
  93.         if (PopTimer) {
  94.             window.clearTimeout(PopTimer);
  95.             PopTimer = null;
  96.         }
  97.         if (!HideTimer && PopElt!=null)
  98.             HideTimer = window.setTimeout(HidePopup,
  99.                 500);
  100.     }

  101.     function IsButton(elt) {
  102.         try {
  103.             return elt.localName=='toolbarbutton' || elt
  104.                 .localName=='button';
  105.         }catch(e) { return false; }
  106.     }

  107.     function IsMenuButton(elt) {
  108.         if (!IsButton(elt)) return false;
  109.         for(var i=0; i<2; i++) {
  110.             try {
  111.                 var nodes = i==0x01 ? elt.childNodes : elt.
  112.                     ownerDocument.getAnonymousNodes(elt);
  113.                 if (nodes!=null && nodes.length && nodes[0]
  114.                     .localName=='menupopup')
  115.                     return true;
  116.             }catch(e) {}
  117.         }
  118.         return false;
  119.     }

  120.     function EnumElement(elt) {
  121.         try {
  122.             if (elt.localName == 'prefpane') {
  123.                 elt.addEventListener('paneload', function(e) {
  124.                     setTimeout(function() { EnumElement(e.
  125.                         target); }, 100);
  126.                     }, false);
  127.             }
  128.             else if(elt.id=='sidebar' && !elt.hasAttribute(
  129.                 'AutoPopup')) {
  130.                 elt.setAttribute('AutoPopup', true)
  131.                 elt.addEventListener('SidebarFocused',
  132.                     function(e) { EnumElement(elt); }, false);
  133.             }
  134.             else if(elt.id == 'editBookmarkPanel')
  135.                 return;
  136.         }catch(e) {}

  137.         for(var i=0; i<2; i++) {
  138.             var nodes = null;
  139.             try {
  140.                 if (elt.localName == 'browser') {
  141.                     i = 1;
  142.                     nodes = elt.contentDocument.childNodes;
  143.                 }
  144.                 else
  145.                     nodes = i==0x01 ? elt.childNodes : elt.
  146.                         ownerDocument.getAnonymousNodes(elt);
  147.             }catch(e) { nodes = null; }
  148.             if (nodes == null) continue;

  149.             for(var n=0; n<nodes.length; n++) {
  150.                 try {
  151.                     var node = nodes[n];
  152.                     if ('PopupAutoComplete'==node.getAttribute(
  153.                         'id').substr(0,17) || 'menupopup'==node
  154.                         .localName || node.localName=='popup')
  155.                         ;
  156.                     else if (node.localName != 'dropmarker') {
  157.                         if (node.localName=='menu' && 'menubar'
  158.                             ==node.parentNode.localName)
  159.                             ;
  160.                         else if(!IsMenuButton(node))
  161.                             node = null;
  162.                     }
  163.                     else if(node.getAttribute('type')=='menu') {
  164.                         node = node.parentNode;
  165.                         if (!node.firstChild || node.firstChild.
  166.                             localName!='menupopup')
  167.                             continue;
  168.                     }
  169.                     if (node == null) {
  170.                         EnumElement(nodes[n]); continue;
  171.                     }
  172.                     if (node.hasAttribute('command')) continue;

  173.                     node.addEventListener('mouseout', MouseOut,
  174.                         false);
  175.                     node.addEventListener('mouseover',MouseOver,
  176.                         false);
  177.                 }catch(e) {}
  178.             }
  179.         }
  180.     }

  181.     setTimeout(function() { EnumElement(document); }, 100);
  182. }}
  183.   autopopupxul.runautopopup();
  184.   ]]></script>
  185. </overlay>
复制代码
评论
精彩评论 ( 1条 ) 跳转到指定楼层
沙发
风云之风 [初入江湖] 发表于 2016-2-1 20:08:53 | 只看该作者
个人感觉没必要,弄不好还会影响正常的使用
您需要登录后才可以回帖 登录 | 加入傲游社区
快速回复 返回顶部 返回列表