2016-10-16 77 views
0

是否可以將此Chrome插件轉換爲在Firefox中工作?在Firefox中顯示模式對話框

https://github.com/chuckhendo/showModalDialog-shim

插件需要window.open

'use strict'; 

var shim = '(' + function() { 
if(typeof window.showModalDialog !== 'function') { 
    window.showModalDialog = function() { 
     var opts = arguments[2]; 
     opts = opts 
      .replace(/;/g, ',') 
      .replace(/:/g, '=') 
      .replace(/dialogWidth/g, 'width') 
      .replace(/dialogHeight/g, 'height') 
      .replace(/center/g, 'centerScreen'); 
     return window.open.call(this, arguments[0], '_blank', opts); 
    }; 
} 
} + ')();'; 

var scriptEl = document.createElement('script'); 
scriptEl.textContent = shim; 
(document.head||document.documentElement).appendChild(scriptEl); 

回答

0

更換window.showModalDialog可以由Greasemonkey運行此。安裝GreaseMonkey擴展,然後將上面的代碼添加爲用戶腳本。

這是改寫GreaseMoney:

// ==UserScript== 
// @name  AddShowModal 
// @namespace http://www.weirdies.net 
// @version  1 
// @grant  none 
// @include  * 
// ==/UserScript== 

(function() { 
    var shim = '(' + function() { 
    if(typeof window.showModalDialog !== 'function') { 
     window.showModalDialog = function() { 
     var opts = arguments[2]; 
     opts = opts 
     .replace(/;/g, ',') 
     .replace(/:/g, '=') 
     .replace(/dialogWidth/g, 'width') 
     .replace(/dialogHeight/g, 'height') 
     .replace(/center/g, 'centerScreen'); 
    return window.open.call(this, arguments[0], '_blank', opts); 
    }; 
} 
} + ')();'; 



var scriptEl = document.createElement('script'); 
scriptEl.textContent = shim; 
(document.head||document.documentElement).appendChild(scriptEl); 
})(); 

我證實,它與OWA 10工程,以彈出對話框附加等,而無需dom.disable_window_showModalDialog設置爲false,禁用Electolysis。它看起來有點笨拙,它似乎沒有適當地轉換寬度和高度(它全屏打開,我沒有時間去調試它),但它的工作原理。

相關問題