Last active
November 27, 2019 10:10
-
-
Save taichunmin/b480b8322b5cf0eadbfbc07f3dd2e485 to your computer and use it in GitHub Desktop.
這是為了讓微程式的 Portal 系統支援 Chrome,需先安裝 Greasemonkey 或 Tampermonkey 才能執行! 下方連結是安裝網址。 https://gist.github.com/taichunmin/b480b8322b5cf0eadbfbc07f3dd2e485/raw/mp-portal.user.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Microprogram Portal | |
// @namespace http://ef.program.com.tw:8081/ | |
// @version 1.16 | |
// @description try to let portal support Chrome | |
// @author taichunmin <taichunmin@gmail.com> | |
// @website https://gist.github.com/taichunmin/b480b8322b5cf0eadbfbc07f3dd2e485/ | |
// @updateURL https://gist.github.com/taichunmin/b480b8322b5cf0eadbfbc07f3dd2e485/raw/mp-portal.user.js | |
// @downloadURL https://gist.github.com/taichunmin/b480b8322b5cf0eadbfbc07f3dd2e485/raw/mp-portal.user.js | |
// @match http://ef.program.com.tw:8081/* | |
// @match http://211.23.134.172/* | |
// @match http://hrmess.program.com.tw/* | |
// @run-at document-start | |
// @grant none | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js | |
// ==/UserScript== | |
(function ($) { | |
// fix connection header error 2019/11/27 | |
XMLHttpRequest.prototype.setRequestHeader1 = XMLHttpRequest.prototype.setRequestHeader | |
XMLHttpRequest.prototype.setRequestHeader = function (header, value) { | |
if (header === 'Connection') return | |
this.setRequestHeader1(header, value) | |
} | |
// 讓 setUrl 這個函式能夠支援 Chrome (需延後執行) | |
setTimeout(() => { | |
if (window.setUrl) { | |
let str = window.setUrl.toString(); | |
str = str | |
.replace(/if \(checkIsChrome\(\)\)\s+\{\s+\/\/ToDo/g, 'if (false)\n{\n //ToDo') | |
.replace('function setUrl(', 'window.setUrl = function('); | |
new Function(str)(); | |
} | |
}, 500); | |
})(jQuery.noConflict(true)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment