相关疑难解决方法(0)

多次在同一页面上运行Greasemonkey脚本?

我是Greasemonkey,javascript的新手,实际上是所有UI的东西.

要求:用户脚本在页面加载后由GS运行一次.但是,我需要在不刷新的情况下多次运行相同的脚本

使用案例:例如,使用Ajax进行Amazon.com搜索.我需要在搜索结果中嵌入自定义元素.

每次在同一页面中进行搜索时,我都需要将我的内容注入search-results-div以及结果(没有页面刷新)

我当前的脚本仅在页面刷新时运行.

我希望上面的解释清楚.请帮忙.

javascript ajax greasemonkey tampermonkey

31
推荐指数
2
解决办法
1万
查看次数

了解Greasemonkey如何运行用户脚本

我正在学习Greasemonkey,希望对网页进行一些改进.

我想我已经很好地掌握了JavaScript,但是我不明白在文档的呈现中在什么时候执行Greasemonkey用户脚本.

例如,如果文档中本身存在JavaScript,则会向页面插入一些元素.我希望我的Greasemonkey脚本只在JS完成后运行.

假设这是我试图用Greasemonkey修改的文档

<html>
 <script>
   //insert a button with id="mybutton"
 </script>
</html>
Run Code Online (Sandbox Code Playgroud)

我想在<script>运行Greasemonkey脚本之前完成代码,因为我想改变它的背景颜色.

javascript greasemonkey

13
推荐指数
1
解决办法
1万
查看次数

在页面加载时运行 TamperMokey 脚本

我编写了一个脚本,当前在 GreaseMonkey 中的页面加载时工作。但是,当我将此脚本传输到 TamperMonkey(在 Chrome 中)时,该脚本拒绝在页面加载时运行。

查看脚本:

// ==UserScript==
// @name     Redirect_ADFS
// @author      Eskimonian
// @version     2018.08.20
// @description     Auto Redirect ADFS Sites to Internal Login Page
// @run-at      document-end
// ==/UserScript==

window.onload = function Redirect() {
  var currenturl = window.location.href //define current URL
  if(currenturl.indexOf("/adfs") > -1) {
    var newurl = "//" + new URL(document.referrer).hostname + '/admin?saml=off'; //set destination URL
    alert("[Eskimo.1] SAML Site Detected. Redirecting to Internal Login page.")
window.location = newurl
  }
} //redirect URL if the currently …
Run Code Online (Sandbox Code Playgroud)

javascript greasemonkey tampermonkey

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

greasemonkey ×3

javascript ×3

tampermonkey ×2

ajax ×1