目标页面的 URL 为: ouo.io/tLnpEc.html
我想将网址更改为:ouo.press/tLnpEc
即:.ioto.press和remove .html。
我已经有了这个,但它不起作用(它重定向到 ouo.press 但仍然没有删除 .html):
var url = window.location.host;
if (url.match("//ouo.io") === null) {
url = window.location.href;
if (url.match("//ouo.io") !== null){
url = url.replace("//ouo.io", "//ouo.press");
} else if (url.match("/*.html") !== null){
url = url.replace("/*.html", " ");
} else {
return;
}
console.log(url);
window.location.replace(url);
}
Run Code Online (Sandbox Code Playgroud)
我希望有人可以帮助解决这个问题。
我正在开发一个需要chrome对象的用户脚本,但我无法访问它。如何访问chrometampermonkey 用户脚本内的对象?也许,清单中的一些权限或者什么......
我正在尝试访问一个网站,但它不允许我这样做,因为它不支持我的浏览器。我相信它正在通过 userAgent 检测来检测我的浏览器。因此,我想创建一个 userScript 来修改我的 userAgent,以便网站无法检测到我的浏览器。我试过:
// ==UserScript==
// @name Change UserAgent
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Spoofs the userAgent
// @author You
// @include *
// @run-at document-start
// ==/UserScript==
Object.defineProperty(navigator, 'userAgent', {
value: "MyCustomUserAgent",
configurable: false
});
Run Code Online (Sandbox Code Playgroud)
尽管它向我表明 userAgent 是一个自定义值,但我相信对 userAgent 的请求在我可以欺骗它之前就已完成。有什么方法可以在不使用扩展的情况下做到这一点?谢谢。
Tampermonkey 在我的用户脚本的语句中有一个弃用警告@include:
// @include /https\:\/\/([a-z\.]*\.)?(((stackexchange|askubuntu|superuser|serverfault|stackoverflow|stackapps)\.com)|(mathoverflow\.net))\/.*/
// @exclude /^https://(chat|api|data)\./
// @exclude https://stackexchange.com/*
Run Code Online (Sandbox Code Playgroud)
eslint: userscripts/better-use-match - 使用 @include 可能不安全,并且可能会在 2023 年初的 Manifest v3 中过时。请切换到 @match。
或多或少等于@include 标签。您可以在这里获取更多信息。注意:该
<all_urls>语句尚不支持,scheme 部分也接受http*://.允许多个标签实例。
然而,尽管有这些不太有用的文档,但它们根本不等同。这不起作用:
// @match /https\:\/\/([a-z\.]*\.)?(((stackexchange|askubuntu|superuser|serverfault|stackoverflow|stackapps)\.com)|(mathoverflow\.net))\/.*/
Run Code Online (Sandbox Code Playgroud)
这里的链接根本没有提到正则表达式!如何将此正则表达式转换为在 中使用 @match?
我在工作中使用具有可怕UI的产品并试图通过Chrome中的UserScripts使其变得美味.为此,我试图通过UserScripts机制将JavaScript函数注入页面:
// find the div
var dropDown = document.getElementById("tstGlobalNavigation_ddlChooseProject");
// inject function
dropDown.innerHTML = dropDown.innerHTML + "<script>function gotoIncident(){alert('111')}</script>";
// inject a button
dropDown.innerHTML = dropDown.innerHTML + " <input type='button' name='btnSearch' value='Go' onClick='javascript:gotoIncident()' >";
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在注入一个按钮和一个函数(gotoIncident),当用户单击该按钮时它将触发.
按钮确实出现在屏幕上但是当我点击它时,javascript调试器告诉我gotoIncident没有定义.
我错过了什么?
我想使用JavaScript为chrome://extensions/页面添加搜索栏,所以我创建了一个名为test.user.js的文件,并在其中编写脚本:
// ==UserScript==
// @name chromeex
// @namespace chromeex
// @version v1.0
/* @reason
* just a test
* @end
*/
// @match chrome://extensions/
//
// ==/UserScript==
(function(){
alert("haha");
}());
Run Code Online (Sandbox Code Playgroud)
但是当我在Chrome中加载它时,它说无效标题,最后我发现它@match chrome://extensions/是导致错误的.有没有一个解决方案?
javascript google-chrome userscripts google-chrome-extension
我一直在寻找一段时间,但我能找到的只是如何实际提出这些要求的例子......
我要做的是在点击X站点的按钮后检查网站是否正在发出http请求
防爆.http://test.s3.amazonaws.com/test/1.txt
我猜有一种方法来获取所有传出的请求,然后过滤列表,但我甚至无法得到请求
到目前为止我所做的只是插入eventlistener以检查是否已单击X按钮,然后是我想要检查这些请求的时间.
<script language="javascript">
document.getElementById("button").addEventListener('click', buttonClicked, true);
function buttonClicked(){
-->Check requests made after button is clicked.<--
}
</script>
Run Code Online (Sandbox Code Playgroud) javascript greasemonkey xmlhttprequest userscripts http-headers
在我的用户脚本中,我创建了一个document.createElement的钩子,我使用的代码是Brock adams在下面的帖子中提供的解决方案
现在当我在firefox中运行这个用户脚本并打印这样的elemin LogNewTagCreations ()方法console.log(elem)时,我得到了[object XrayWrapper [object HTMLDivElement]]这种格式的输出.现在,我怎样才能得到innerHTML标签或整个标签这样的属性<div>Sometext</div>,这样我可以得到innerHTML从这个
我目前正在将用户脚本更新为Chrome扩展程序,但由于新ID不同,因此不会更新旧扩展程序,而是添加新扩展程序.
有没有办法将用户脚本转换为Chrome扩展程序并保留相同的ID?
由于没有用户脚本的密钥文件,我认为它可能,
但如何?
我需要在公司内部网站上托管用户脚本。我如何构建该链接href以便Greasemonkey在单击链接时安装用户脚本?
我尝试了一个简单的方法,<a href="user.js">Install Userscript</a>但Chrome和Firefox仅显示文件源,而不安装用户脚本。
userscripts ×10
javascript ×8
greasemonkey ×3
tampermonkey ×3
detection ×1
http-headers ×1
include ×1
permissions ×1
regex ×1
spoofing ×1
url ×1
user-agent ×1