ybbao
非常火狐
非常火狐
  • UID27616
  • 注册日期2008-12-29
  • 最后登录2023-05-21
  • 发帖数721
  • 经验53枚
  • 威望0点
  • 贡献值36点
  • 好评度1点
  • 社区居民
阅读:1944回复:6

【nightly】autocopy脚本和扩展失效

楼主#
更多 发布于:2015-10-05 07:15
求更新或有一个能用的。
文科
千年狐狸
千年狐狸
  • UID39959
  • 注册日期2013-10-17
  • 最后登录2019-07-27
  • 发帖数2069
  • 经验1328枚
  • 威望4点
  • 贡献值340点
  • 好评度256点
  • 最爱沙发
  • 社区居民
  • 忠实会员
1楼#
发布于:2015-10-05 11:04
ybbao
非常火狐
非常火狐
  • UID27616
  • 注册日期2008-12-29
  • 最后登录2023-05-21
  • 发帖数721
  • 经验53枚
  • 威望0点
  • 贡献值36点
  • 好评度1点
  • 社区居民
2楼#
发布于:2015-10-05 18:24
试过最新的44版,全新配置,无法使用。
eagle5678
千年狐狸
千年狐狸
  • UID4956
  • 注册日期2005-04-10
  • 最后登录2023-04-02
  • 发帖数1247
  • 经验204枚
  • 威望0点
  • 贡献值120点
  • 好评度3点
3楼#
发布于:2015-10-09 15:20
41下2个copy都不能用,换脚本了
ybbao
非常火狐
非常火狐
  • UID27616
  • 注册日期2008-12-29
  • 最后登录2023-05-21
  • 发帖数721
  • 经验53枚
  • 威望0点
  • 贡献值36点
  • 好评度1点
  • 社区居民
4楼#
发布于:2015-10-26 12:01
有合适的脚本?
云中水
小狐狸
小狐狸
  • UID42542
  • 注册日期2013-11-30
  • 最后登录2018-02-13
  • 发帖数12
  • 经验30枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
  • 忠实会员
5楼#
发布于:2015-10-31 21:30
// ==UserScript==
// @name           autoCopyToClipboard.uc.js
// @namespace      http://space.geocities.yahoo.co.jp/gl/alice0775
// @description    自动复制开关菜单版
// @include        main
// @author         Alice0775
// @version        2013/11/22 02:00 Abort "can't access dead object" error
// @version        2013/01/08 02:00 Bug 827546
// ==/UserScript==
// @version        2013/09/13 00:00 Bug 856437 Remove Components.lookupMethod
// @version        2012/12/08 22:30 Bug 788290 Bug 788293 Remove E4X 
// @version        2008/02/19 18:00
// @note           Ctrl+Shift+C または about:config の clipboard.autocopy を [false]で无効 true で 有効 トグル
// @note           designModeやtextarea等编集可能要素なら何もしない
  
var autoCopy = {
  // --config--
  YOURKEYINSPEED: 100,
  YOURCLICKSPEED: 500,
  // --config--
  PREF: "clipboard.autocopy",
  timer: null,
  menuitem: null,
  
  init: function() {
  
    var overlay = ' \
      <overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" \
               xmlns:html="http://www.w3.org/1999/xhtml"> \
        <keyset id="mainKeyset"> \
          <key id="key_toggleAutoCopy" \
               oncommand="autoCopy.toggle();" \
               key="C" \
               modifiers="accel, shift"/> \
        </keyset> \
        <menupopup id="menu_ToolsPopup"> \
              <menuitem insertbefore="menu_preferences" \
                        id="autoCopy" \
                        label="自动复制开关" \
                        type="checkbox" \
                        checked="false" \
                        accesskey="A;" \
                        oncommand="autoCopy.toggle();"/> \
        </menupopup> \
      </overlay>';
    overlay = "data:application/vnd.mozilla.xul+xml;charset=utf-8," + encodeURI(overlay);
    window.userChrome_js.loadOverlay(overlay, autoCopy);
  },
  
  observe: function(){
    window.addEventListener("unload", this, false);
    document.getElementById("menu_ToolsPopup").addEventListener("popupshowing", this, false);
    gBrowser.mPanelContainer.addEventListener('mouseup', this , true);
    gBrowser.mPanelContainer.addEventListener('keyup', this , true);
    this.menuitem = document.getElementById("autoCopy");
  },
  
  uninit: function() {
    window.removeEventListener("unload", this, false);
    document.getElementById("menu_ToolsPopup").removeEventListener("popupshowing", this, false);
    gBrowser.mPanelContainer.removeEventListener('mouseup', this , true);
    gBrowser.mPanelContainer.removeEventListener('keyup', this , true);
  },
  
  handleEvent: function(aEvent) {
    switch(aEvent.type) {
      case 'unload':
        this.uninit();
        break;
      case 'popupshowing':
        this.popupshowing();
        break;
      case 'mouseup':
        this.mouseup(aEvent);
        break;
      case 'keyup':
        this.keyup(aEvent);
        break;
    }
  },
  
  popupshowing: function() {
    if (this.menuitem)
      this.menuitem.setAttribute('checked', gPrefService.getBoolPref(this.PREF));
  },
  
  toggle: function() {
    gPrefService.setBoolPref(this.PREF, !gPrefService.getBoolPref(this.PREF));
  },
  
  mouseup: function(aEvent) {
    if (this.timer)
      clearTimeout(this.timer);
    this.timer = setTimeout(function(aEvent, self) {
      self.copyToClipboard(aEvent);
    }, this.YOURCLICKSPEED, aEvent, this);
  },
  
  keyup: function(aEvent) {
    if (this.timer)
      clearTimeout(this.timer);
    this.timer = setTimeout(function(aEvent, self) {
      self.copyToClipboard(aEvent);
    }, this.YOURKEYINSPEED, aEvent, this);
  },
  
  copyToClipboard: function(aEvent) {
  //ドキュメントとコンテントタイプ
    try {
      var doc = aEvent.target.ownerDocument;
    } catch(e) {
      // "can't access dead object" error
      return;
    }
    if(!doc
       || doc.contentType != 'text/plain'
       && doc.contentType != 'text/html'
       && doc.contentType != 'application/xml'
       && doc.contentType != 'application/xhtml+xml')
      return;
    // designModeなら何もしない
    if (doc.designMode == 'on')
      return;
    // textarea等编集可能要素なら何もしない
    if (this.isParentEditableNode(aEvent.target))
      return;
    // pref chrck
    if (!gPrefService.getBoolPref(this.PREF) )
      return;
  
    if (aEvent.type == "mouseup" && aEvent.button == 0) {
      goDoCommand('cmd_copy');
      return;
    }
    if (aEvent.type == "keyup" && aEvent.shiftKey) {
      switch (aEvent.keyCode) {
        case KeyEvent.DOM_VK_END:
        case KeyEvent.DOM_VK_HOME:
        case KeyEvent.DOM_VK_LEFT:
        case KeyEvent.DOM_VK_UP:
        case KeyEvent.DOM_VK_RIGHT:
        case KeyEvent.DOM_VK_DOWN:
          // do
          goDoCommand('cmd_copy');
      }
    }
  },
  
  isParentEditableNode: function(node) {
    while (node && node.parentNode) {
      try {
        if (!(node instanceof Ci.nsIDOMNSEditableElement))
          throw 0;
        node.QueryInterface(Ci.nsIDOMNSEditableElement);
        return node;
      }
      catch(e) {
      }
      if (node.isContentEditable || node.contentEditable == 'true')
        return node;
      node = node.parentNode;
    }
    return null;
  }
}
autoCopy.init();
42上正常使用
ybbao
非常火狐
非常火狐
  • UID27616
  • 注册日期2008-12-29
  • 最后登录2023-05-21
  • 发帖数721
  • 经验53枚
  • 威望0点
  • 贡献值36点
  • 好评度1点
  • 社区居民
6楼#
发布于:2015-12-13 10:46
试过,还是不行
游客

返回顶部