<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>theDeSilva.com&#187; function</title>
	<atom:link href="http://www.thedesilva.com/tag/function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedesilva.com</link>
	<description>Andrew de Silva</description>
	<lastBuildDate>Tue, 26 Apr 2011 20:24:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Greasemonkey &#8211; Add button to page to call function within GreaseMonkey</title>
		<link>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/</link>
		<comments>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 22:14:51 +0000</pubDate>
		<dc:creator>Andrew de Silva</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[onclick]]></category>

		<guid isPermaLink="false">http://www.thedesilva.com/?p=180</guid>
		<description><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/>Here&#8217;s a really quick way to add a button into an existing page and then have the button call a function that is within greasemonkey script. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 &#160; window.addEventListener&#40;&#34;load&#34;, function&#40;e&#41; &#123; addButton&#40;&#41;; &#125;, false&#41;; &#160; function addButton&#40;&#41;&#123; [...]]]></description>
			<content:encoded><![CDATA[<img src="http://www.thedesilva.com/img/category_icon//java-duke-logo-small.png" width="60" height="60" alt="" title="Javascript" /><br/><p>Here&#8217;s a really quick way to add a button into an existing page and then have the button call a function that is within greasemonkey script.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;load&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  addButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addButton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> buttonElems <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'buttonElementName'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 buttonElems<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> buttonElems<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;input id=&quot;greasemonkeyButton&quot; type=&quot;button&quot; value=&quot;Call Greasemonkey Function&quot; /&gt;'</span>
addButtonListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addButtonListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> button <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;greasemonkeyButton&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  button.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span>doMonkey<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> doMonkey<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//do something</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thedesilva.com/2010/01/greasemonkey-add-button-to-page-to-call-function-within-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

