本帖最后由 大药科技 于 2021-7-9 15:40 编辑
html源码如下,我想使用油猴来改变原先openWindow函数由原来的在小窗口打开改为浏览器新标签打开,但是我怎么改都不行,不放在(function(){****})()也不行,望高手指点指点!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试页</title></title>
<script>
function openWindow(url, width, height) {
if (width == '') {
width = screen.width - 20;
}
if (height == '') {
height = screen.height - 120;
}
var win = window.open(url, '', 'height=' + height + 'px,width=' + width
+ 'px,resizable=yes,toolbar:0,menubar:0,scrollbars=1');
return win;
}
</script>
</head>
<body>
<a href="javascript:void(0);" onclick="javascript:openWindow('https://baidu.com','','')">综合办理</a>
</body>
</html>
油猴代码如下:
// ==UserScript==
// @name 广西医疗基层window.open改写
// @namespace 6666666666
// @include ***************
// @run-at document-idle
// ==/UserScript==
(function(){
function openWindow(url, width, height) {
if (width == '') {
width = screen.width - 20;
}
if (height == '') {
height = screen.height - 120;
}
// if (url.indexOf('?') > 0) {
// url += "&username=" + cjkEncode(user_username);
// } else {
// url += "?username=" + cjkEncode(user_username);
// }
var win = window.open(url);
return win;
}
})();