English 中文(简体)
Greasememonkey: 拦截上载事件
原标题:Greasemonkey: Intercept inline onload event

能否通过 GreaseMonkey 修改/ 取消一个 < code_ lt; body onload=" "... " " "> 事件?

有关法典是:

<body onload="if (document.body.scrollIntoView &amp;&amp; (window.location.href.indexOf( # ) == -1 || window.location.href.indexOf( #post ) &gt; -1)) { fetch_object( currentPost ).scrollIntoView(true); }">

我想完全阻止它执行(即使URL里没有散列物, 使用“ 回扣”按钮显然也会触发散列物,

最佳回答

是的,您可以截取 // ==UserScript== // @name _Block inline onload function // @namespace _pc // @include http://YOUR_SERVER/YOUR_PATH/* // @run-at document-start // ==/UserScript== document.addEventListener ("readystatechange", FireWhenReady, true); function FireWhenReady () { this.fired = this.fired || false; if ( document.readyState != "uninitialized" && document.readyState != "loading" && ! this.fired ) { this.fired = true; document.body.onload = function () { console.log ("body onload intercepted."); }; } }

问题回答

暂无回答




相关问题
Call href from JavaScript

This is the same question as THIS ONE, I can t answer that anymore, so I m re-posting it with my account. Sorry for the mess. I need a Greasemonkey script that on a page load activates a href link ...

form.submit() causes uncaught exception in greasemonkey

I m using a greasemonkey script to load a page with ajax and automatically fill in the form fields inside the page and submit the form. The problem is that when the form.submit() statement is executed ...

Can I build an addin for Gmail?

Is there a way I can create an addin for my Gmail account? Is GreaseMonkey the only real way? I use Gmail for customer service, and I d like to create a tool that looks up the customer and preps a ...

Is nested XMLHttpRequests with multiple closures a good idea?

I have a Greasemonkey script which operates on a search results page at a video site. The function of the script is to take a javascript link that opens a new window with a flash player, jump through ...

jQuery data() function in GreaseMonkey

I m trying to use jQuery s data() function to store and retrieve data on an element. I want to retrieve the data stored in a textarea whenever the user enters the space bar1. However, everytime I do ...

GreaseMonkey onclick binding

When I write a GreaseMonkey script, if I create a div and set onclick to alert it works: var btn = document.createElement( div ); btn.setAttribute( onclick ,"alert( clicked! );"); However, if I ask ...

热门标签