AppendChild In Greasemonkey
Jul 23, 2005
I'm using the following code in a Greasemonkey script.
var start, newElement;
start = document.body;
newElement = document.createElement('b');
newText = document.createTextNode("The Greasemonkey salutes you!");
newElement.appendChild(newText);
start.appendChild(newElement);
Can anyone tell me: 1) why my string appears twice; 2) how to make it
appear just once?
I'm trying to insert code at the top of every viewed page. Obviously,
document.body appends the string to the closing body tag which is not
what I want. What could I use to insert my code as the first childnode
under 'body'?
View 3 Replies
ADVERTISEMENT
Dec 27, 2006
I'm new to Greasemonkey, and have no idea how to fix this. I would post elsewhere, but I couldn't find a forum for user script development help....
View 4 Replies
View Related
Mar 22, 2006
I'm trying to write a script (my first) that loops through some table
rows and gets some data from another page using gm_xmlhttprequests. It
works if I keep the loop to one, but if I try and loop through all the
rows, and therefore have say 10-20 gm_xmlhttprequests, the script just
seems to fail. But if I put an alert inside each gm_xmlhttprequest, and
wait a bit before dismissing the alert, the gm_xmlhttprequest will
succeed and the data gets updated as planned. It seems as if the
gm_xmlhttprequests don't block, or the script keeps executing without
waiting for the requests to finish. I don't have any listeners on the
script, I just want it all to load when the page loads. Also, I looked
at the javascript console and it doesn't have any errors about the
gm_xmlhttprequests.
View 1 Replies
View Related
Mar 4, 2009
Without getting into whether I should or shouldn't do this, I'm hoping someone can help me disable greasemonkey on my site.
I've tried the two methods I could find via Google, but neither worked code...
Is there actually a way to prevent Greasemonkey from loading on your page?
View 2 Replies
View Related
Feb 12, 2010
I am trying to learn some javascript at the moment and thought a simple greasemonkey script might be a good way to start.What I want the script to do is to replace an existing url on a website with a different url from another location within the website.
E.G. replace "/mailbox.php?inbox" with "/account.php?action=mybookmarks"
There are a lot of examples of replacing existing urls with different ones on the web but they all use id's to locate and replace urls.
This script is for a site I visit often and since I dont own it I dont have the ability to add id tags to the appropriate a tags, this makes writing this script a lot more difficult.This is the code I have so far;
Code:
// ==UserScript==
// @name NZBmatrix mailbox url replace
// @include http://nzbmatrix.com/
[code]....
View 3 Replies
View Related
May 7, 2010
would like to know a tool that could give me a clue on where is the error in a greasemonkey script that i'm working on. I'm using notepad, what tool could "run" the script and tell me where is the error?
View 4 Replies
View Related
May 6, 2007
javascript:(function(){var k,x,t,i,j,p; for(k=0;x=document.links[k];k+
+){t=x.href.replace(/[%]3A/ig,':').replace(/[%]2f/
ig,'/');i=t.lastIndexOf('http');if(i>0){ t=t.substring(i);
j=t.indexOf('&'); if(j>0)t=t.substring(0,j); p=/https?://[^
s]*[^.,;'%22>s)]]/.exec(unescape(t)); if(p) x.href=p[0]; } else if
(x.onmouseover&&x.onmouseout){x.onmouseover(); if (window.status &&
window.status.indexOf('://')!=-1)x.href=window.status;
x.onmouseout(); } x. x. }})();
View 1 Replies
View Related
Mar 21, 2009
What I would like to do is watch a countdown timer on a page, like the ones on swoopo.co.uk and then perfom an action depending on what time is left on the timer.
I've installed DOM inspector on Firefox and poked around with javascript shell and I think I've figured out how to read the timer and assign that to a variable, something like this -
var timer=document.getElementById('counter_index_page_162980').innerHTML;
Now I need to watch that so I guessed this would do -
while (timer!=="00:00:01")
{
var timer=document.getElementById('counter_index_page_162980').innerHTML;
}
alert('timer at 1 sec!');
But that just brings up an "unresponsive script" error in my browser.
Am I even close to the mark? I know I'm not going to win any auctions with this but I've already paid for the bids so I may as well use them now.
View 1 Replies
View Related
May 8, 2010
I'm using this script:
[URL]
source code:
[URL]
but it's showing no checkboxes. Here's the code related to that:
Code:
function rp_villageSelector() { //adds Village checkboxes
FM_log(3,"rp_villageSelector() called");
//get Travian Version
[code]....
View 1 Replies
View Related
Nov 27, 2006
I'm a newbie to JavaScript and Greasemonkey and just started learning
with 'Dive Into Greasemonkey'. I looked for an example on the web, but
unfortunately I'm still missing something...
I have a text file which is a simple database:
Key01 Text01 Url01
Key02 Text02 Url02
....
I'd like to insert after
<a href="anUrl" class="thisClass">Key01<a>
the element
<a href="Url01">Text01<a>
I tried to reuse the "Dumb Quotes" from 'Dive Into Greasemonkey' by
replacing
replacement = {
"Key01":"Key01</a><a href="Url01">Text01",
"Key02":"Key02</a><a href="Url01">Text02"
};
Unfortunately, this doesn't work, since </a><a href...is not
interpreted as a HTML tag.
So I tried this:
nodes = document.evaluate(
"//text()",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < nodes.snapshotLength; i++) {
node = nodes.snapshotItem(i);
text = node.data;
for (key in replacements) {
if(s==key)
helpkey=key;
}
newLink = document.createElement('a');
// newLink.href = 'Url0x' ????
// newLink.appendChild(document.createTextNode(Text0x )); ???
newLink.parentNode.insertBefore(newLink, node.nextSibling);
}
I'm really lost.
View 2 Replies
View Related
Jan 14, 2010
I've just started some JavaScript development, but have run into a bit of a problem with a Greasemonkey script I'm working on. This script is for personal use. I'm doing a variety of things on a page, including auto-refreshing it. I want to display the number of clicks (preferably just on links) since the last refresh.
View 1 Replies
View Related
Jan 27, 2006
I cannot get an appendChild(img) in the following code snippet to work in IE. However, the same script works without any problems in Firefox and Netscape 7.0 The error that is produced in IE is invalid argument. I have used a try/catch block in expectation of producing a better error message however the error message that is received is [objectError].
var pageDiv = window.parent.fraTop.document.getElementById('pageTitle');
if(pageDiv!=null)
{
while(pageDiv.hasChildNodes())
{
pageDiv.removeChild(pageDiv.firstChild);
}
var img = document.createElement('img');
img.src='/wp2f/images/please_wait.gif'
pageDiv.appendChild(img);
}
View 2 Replies
View Related
Jan 30, 2010
I have this body:
<body>
<div id="d1">content</div>
<!--I want to append a div right here-->
<div id="d3">content</div>
</body>
I have this javascript code which would add a div after div id="d3":
var adiv = document.createElement("div");
document.body.appendChild(adiv);
How could I modify my javascript code so that instead of adding to the end, making it the last tag, it would be the second tag?
View 2 Replies
View Related
Aug 23, 2006
I'm trying to spread a table across a frameset. So I have index.htm that has an iframe sourcing the frameset. What I'm trying to do is create a table in index.htm to spread across the whole brower window. Code:
View 2 Replies
View Related
Jul 20, 2005
<body id="theBody">
<p> 1
<p> 2
<p> 3
<p> 4
<p> 5
<p> 6
</body>
var newText = parent.frames[1].document.createTextNode("some text");
var theBody= parent.frames[1].document.getElementById("theBody");
theBody.appendChild(newText);
This will insert an element after the last <p>, can I insert one
after the body but before the first <p>?
View 2 Replies
View Related
Nov 29, 2009
Over the last couple years I've built up a DOM library. Nothing fancy, you can just create an element with all its attributes in one function. What I've wanted to do is make it so you can determine the parent element of the newly created element. Works supa in firefox, not so supa in IE.This is my code....
Code:
pollOptions = document.getElementById("pollOptionsContainer");/*new divs to organize it in*/
pollOptionsGroupContainer = buildHtml.createDivHTMLElement(pollOptions);
[code]....
View 5 Replies
View Related
Sep 11, 2010
Why doesn't the following code work in firefox:
var e = document.createElement("Div");
e.innerHTML = "<p>Hi</p>";
GP.appendChild(e);
..GP is a div..
It works in IE. What is the correct code for FF.
View 4 Replies
View Related
Dec 5, 2011
Need to append a hidden value to a floating div that is made via javascript. I tried the most obvious way but I am getting mismatch error in debug.
.HTML
<input type="hidden" id="desc1" value="blah blah blah" />
.JS
[code]....
View 6 Replies
View Related
May 25, 2006
i'm trying to generate a calendar using dom to create a table. it works in firefox and opera, but ie won't show it, and sometimes gives me an alert saying it can't display the page, and then shows a 404 page. here's the code:
View 3 Replies
View Related
May 21, 2004
I have a simple two frame page (top and bottom; parent called index). and I am trying to dynamically create forms in the bottom frame when buttons are clicked on the top page. But I keep getting an error in the line labelled * below inside addBlock1(). Here is my code (which is in top.html): Code:
View 1 Replies
View Related
Feb 27, 2006
I am trying to append an input box to a table and it doesn't seem to be working at all the code I am using is this:
function makeEdit (oldValue, pageID) {
alert (pageID);
var targetDiv = $(pageID.toString());
var inputBox = document.createElement("input");
inputBox.value=oldValue;
inputBox.id=pageID;
inputBox.onBlur="saveData()";
alert(inputBox);
targetDiv.appendChild(inputBox);
}//makeEdit()...
FYI the $ is just a prototype function for getElementByID the error i keep getting says that "targetDIV has no properties" not sure what that means exacly. Any ideas?
View 3 Replies
View Related
Feb 5, 2011
The .label. is killing the code, but I want to append the child as a label not just plain text.[code]
View 8 Replies
View Related
Jul 23, 2005
I am trying to create one image using JavaScript; then later in the script
remove the image - not just remove the src. The following creates the image, but I have been unable to remove it.
How do I structure
document.getElementById('num1').removeChild(image_ display); ?
<input type=file name="picture1" onChange="image(this.value, 'num1');"
Id="pt1">
<div id='num1'></div>
<script type="text/javascript">
function image_size(field, num){
image_display=document.createElement('img');
image_display.src=field;
document.getElementById('num1').appendChild(image_ display);
..
..
..
document.getElementById('num1').removeChild(image_ display);
}
</script>
View 9 Replies
View Related
Jul 23, 2005
If I try to append a PARAM tag twice I'm having problems:
var.medDiv = document.getElementById("myDiv");
var medObj = document.createElement("object");
var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);
p = document.createElement("param");
p.setAttribute("AutoStart","false");
medObj.appendChild(p); // <-- this one
medDiv.appendChild(medObj);
The line with the "this one" comment triggers IE to tell me that it has
an invalid argument. If I change the order of the PARAMs then the new
second PARAM will give me the error. If I move the setAttribute to after
the appendChild I still get the error.
View 7 Replies
View Related
Nov 23, 2005
This example
will show that the first call to "doit()" will print 30 times the image
with only one call to the server. Then I have a timeout and call doit()
again, and this time, it downloads the picture 30 times!!!! It doesn't
even time to finish downloading the pictures before the next timeout
kicks off and if I let it go for a minute or two i have like 300 calls
to download the same image trying to be downloaded!
I heard about a bug in IE that would require to preload the images
using a hidden div, but that didn't work. I see that google maps manage
to not having to reload the image and gets it from cache. What am I
doing wrong? This works perfectly in Firefox (i.e. it uses the cache
and calls the server just once). Code:
View 4 Replies
View Related
Nov 23, 2005
I have a custom HTML tag: <custom>text is here</custom>
I can do anything I would like in terms of calling methods with mozilla
but not IE 6. For instance calling appendChild in IE results in an
error. The innerHTML property is blank even though there is text
between the tag.
Is there a work around for IE. What gives with IE and being able to
access and manipulate custom tags??
View 1 Replies
View Related