各位大佬 问下网页插入一个DIV菜单如何作?
各位大佬 问下网页插入一个DIV菜单如何作?例如这样的
!(data/attachment/forum/202204/17/102939y5nuai5jji1pgjgr.png) ```javascript
// ==UserScript==
// @name New Userscript
// @match *://*.tampermonkey.net.cn*
// @version 0.1.0
// @descriptiontry to take over the world!
// @author You
// @run-at document-end
// @grant unsafeWindow
// @require https://lib.baomitu.com/jquery/2.0.0/jquery.min.js
// ==/UserScript==
var _w = unsafeWindow,
$ = _w.jQuery || top.jQuery;
(function() {
'use strict';
// Your code here...
var box_html = `<div style="border: 2px dashed rgb(0, 85, 68); width: 330px; position: fixed; top: 50%; left: 0%; z-index: 99999; background-color: rgba(184, 247, 255, 1); overflow-x: auto;">
<h3 style="text-align: center;">div</h3>
<div>
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
</div>
</div>`;
$(box_html).appendTo('body');
})();
```
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAacAAAB1CAYAAADqbi4IAAAWEElEQVR4nO3df1RUZf4H8DceOl/7nlz7YcJkHCPtMMbimMe171kL1wOzDMFUGoqJSi2gxURojpqYuWqi4pSiwpqgGyIqxaobIHBG1+JU66q5jqQNm8pu4waDuS3az207fv+4M3d+PMMAiswF3q9zOKfPnc/c+1zo3I/Pc597n6CrV69eAxH5dOXKFdxzzz3dtr/PLjTjgftV3ba/rvr2+x8CdmyirhgQ6AYQERF5Y3EiIiLFYXEiIiLFYXEiIiLFYXEiIiLFYXEiIiLFYXEiIiLFYXEiIiLFYXEiIiLFYXEiol7IgnWRD2KdxV/KGkRFroGYIn3X92fd5Mv9eC7yQURFzsGBL2/WQfo2Fici6nW+PFCAXRNWI00T6Ja0Y8hkbD1zFkdWA8smdlBEyScWJyJSlC8PzEHUnP1ov8NxCR8c/AAzDZMx5LqOoMHiM2fRcGYJrre2WdY+iOcOXOowb8iT29Bw5iwWK7WIKhiLExEphmXtg5i0tIPCYynGsg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+W4eO82VBx8R8hLS07H1IRkOd59YBd27isR8p5+PAWpSc/I8b6aP2Dbnq1C3uS4KZib8rwc1753EBt3bBDy4ibqMD9tgRy/d/QI1haKz+1MfHgilhhekeNjp/6CV994Rcj7hWY8Vi1YLcenrafl54HcRUVEYf3SN+T4XNNneGF5ppA3YvgIFKxynd/F5otIX/yskDcsZBi2r39Ljv/11WXMyJ4u5N1x+x3Ys+ltOf72u28xZe4TQt6tAwdi/zbX3/PatWuIT/21kNceDusREZHiBF29evVaoBtBpFRXrlzBPffc0237++xCMx64X9Vt++uqb78XH3YkUiL2nIiISHFYnIiISHFYnIiISHFYnIiISHFYnIiISHH63otfiahd/zvwfwLdBKJOYc+JiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgUh8WJiIgU5/8BmTvT6VIp6FsAAAAASUVORK5CYII=
Ne-21 发表于 2022-4-17 11:00
```javascript
// ==UserScript==
// @name New Userscript
大佬就是NB Ne-21 发表于 2022-4-17 10:30
```javascript
// ==UserScript==
// @name New Userscript
大佬 文字 我加了点击链接 但没反应 如何破 承易 发表于 2022-4-17 12:59
大佬 文字 我加了点击链接 但没反应 如何破
给它绑定的点击事件
```javascript
// ==UserScript==
// @name New Userscript
// @match *://*.tampermonkey.net.cn*
// @version 0.1.0
// @descriptiontry to take over the world!
// @author You
// @run-at document-end
// @grant unsafeWindow
// @require https://lib.baomitu.com/jquery/2.0.0/jquery.min.js
// ==/UserScript==
var _w = unsafeWindow,
$ = _w.jQuery || top.jQuery;
(function() {
'use strict';
// Your code here...
var box_html = `<div style="border: 2px dashed rgb(0, 85, 68); width: 330px; position: fixed; top: 50%; left: 0%; z-index: 99999; background-color: rgba(184, 247, 255, 1); overflow-x: auto;">
<h3 style="text-align: center;">div</h3>
<div>
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td id="baidu">跳转百度</td>
<td id="price">$100</td>
</tr>
</table>
</div>
</div>`;
$(box_html).appendTo('body');
$('#price').on('click',function(){
alert("被点击了")
})
$('#baidu').on('click',function(){
_w.location.href = "https://baidu.com"
})
})();
```
Ne-21 发表于 2022-4-17 13:04
给它绑定的点击事件
```javascript
// ==UserScript==
哈哈 NB 又学会了 谢谢大佬 Ne-21 发表于 2022-4-17 13:04
给它绑定的点击事件
```javascript
// ==UserScript==
$('#baidu').on('click',function(){
_w.location.href = "https://baidu.com"
})
在这个 中 打开链接后 ,延迟3秒 在打开上面链接中的 某一个链接 设置完 没用,加了弹出消息 也没反应
// _w.setTimeout("ok1()",5000);//这个执行外部函数也没用
_w.setTimeout(function () {
var biaoti=document.querySelector("#readme > div.Box-body.px-5.pb-5 > article > p:nth-child(3) > a").title;
location.href = biaoti;
alert("2被点击了")
}, 2000);
肯定是我写的有问题 但是什么问题 请看下 承易 发表于 2022-4-17 14:07
$('#baidu').on('click',function(){
_w.location.href = "https://baidu.com"
})
_w.location.href = "https://baidu.com"
直接打开新窗口了,你就不能在操作原来的窗口了,说实话,没看懂你这说的是啥意思 本帖最后由 Ne-21 于 2022-4-17 14:55 编辑
// _w.setTimeout("ok1()",5000);//这个执行外部函数也没用
这玩应直接写 setTimeout(ok1,5000);
或者写 setTimeout(()=>{
ok1()
},5000)
页:
[1]
2