English 中文(简体)
脚本发射,但没有结果
原标题:Script firing but no results

我写了一篇Grease Monkey的文章,在博客中添加一个纽子。 我已提醒大家,我知道一切都在进行。

The strange thing is that it fires twice, slightly differently each time. When I navigate to a blogger.com post edit, the script fires first on a black page and goes through all of the alerts in the right order including the "inside" one.

排在页数之后的第二段,除“侧面”外,每一次警报都发生,没有产生错误。

 // ==UserScript==
 // @name  Blogger: Remove HTML Space
 // @include  http://www.blogger.com/blogger.g?blogID*editor/target*
 // ==/UserScript=

 function contentEval(source) {
   // Check for function input.
   alert("asdas");
   if ( function  == typeof source) {
     // Execute this function with no arguments, by adding parentheses.
     // One set around the function, required for valid syntax, and a
     // second empty set calls the surrounded function.
     source =  (  + source +  )(); 
   }

   alert("asdas2");
   // Create a script node holding this  source code.
   var script = document.createElement( script );
   alert("asdas3");
   script.setAttribute("type", "application/javascript");
   alert("asdas4");
   script.textContent = source;
   alert("asdas5");

   // Insert the script node into the page, so it will run, and immediately
   // remove it to clean up.
   alert("asdas6");
   document.body.appendChild(script);
   alert("asdas7");
 }

  alert("test")
  contentEval(function(){ alert("inside"); document.getElementById("postingHtmlToolbar").firstChild.innerHTML +=  <div id="SP" class="goog-inline-block goog-toolbar-button" title="SP" role="button" style="-moz-user-select: none;"><div class="goog-inline-block goog-toolbar-button-outer-box"><div class="goog-inline-block goog-toolbar-button-inner-box"><button type="button" onclick="document.getElementById( postingHtmlBox ).value = document.getElementById( postingHtmlBox ).value.replace(/&amp;nbsp;/g,    );"><b>SP</b></button></div></div></div> });

 alert("testw");

blogger.com有抗药注射吗?

最佳回答

www.un.org/Depts/DGACM/index_spanish.htm 大约两次发射:

如果该网页包含<iframe>s,用户代码将各自发射。

您需要确定您是否在<代码>和>、iframe>、内。 只有在主页,而不是金字塔,才最简单的火力方式是用以下方式包罗所有代码:

if(top==self)
{
  ...
}

参看<iframe>s in the page (要么是硬编码,要么是动态生成的) 我总是使用AdBlock Plus(“可阻挡物品”)方言。

I m not sure however why the second "inside" alert does not launch. I ve created a simple HTML page containing <iframe> and I get two alerts fired.

www.un.org/Depts/DGACM/index_spanish.htm 描述一般:

你在此重复工作。 你们无需包罗一切,才能执行文字。 Greasemonkey在页面负荷后(DOMContent Loaded)执行代码项目。 因此,你不必创建<代码><script> tag,将其体质和附着文件。 你可以说,

document.getElementById(“postingHtmlToolbar”).firstChild.inner/60/8 += ......

and it should do what you want (you don t need contentEval function at all).

我在博客上没有任何博客,因此,我可以记录和看到任何URL和有问题的行为,但按部就班行事,这应足以缓解。

<><>><>>>>

Seems that You should change firstChild to firstElementChild

There is innerHTML property in Element (since Firefox 3.5), but not in Node. Yeah, it s really inconsistent and annoying at times. I ve come into similar problem recently.

<><><><>>>

那里有两件事。 请不要告诉我,它没有做什么工作:

var func = function() {
    var obj = document.getElementById("postingHtmlToolbar");
    if(obj !== null){ // only if object exists, so we don t have errors
       //alert(obj);
       obj.style.display =  block ; // it s hidden by default
       obj.firstElementChild.innerHTML += "FOO";
    }
 }

 window.setTimeout(func, 3000); // execute with delay -- let s give Google s JS time to be loaded first
问题回答

全球机制可以直接修改一个网页,使全球机制发挥效用。

The <button> tag... don t You mean INPUT?

我认为,由于采用这种方法,我猜测你的工作是无法直接修改这一页。

你们要做的是,你重新创设了名词功能,如果你在联合材料中不曾经历过这种功能,那么“我们”就是这样做的。 这将是一个问题:

if ( function  == typeof source) {
   // Execute this function with no arguments, by adding parentheses.
   // One set around the function, required for valid syntax, and a
   // second empty set calls the surrounded function.
   source =  (  + source +  )(); 
}

当你在+你之间设立“智囊团”时,你将这一职能称为“你”,因为你重新召集,而且作为一种职能并非一种扼杀,当时正在试图胁迫它,因为它履行这一职能,但最后是空洞()再次执行,后来又不执行。 我没有试过,但我确实认为正在发生。

因此,jakub正确地指出,你的法典的复杂性是不必要的,归根结底是给你留下错误。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.