<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Using Violentmonkey scripts]]></title><description><![CDATA[<p dir="auto">How do you get a Violentmonkey script actually to be used?  I imported a script that is supposed to be used with any site, but it is not being used.  The code is here:</p>
<p dir="auto">`<br />
// ==UserScript==<br />
// @name	   Brightness Fixer<br />
// @author	Frenzie<br />
// @version	 0.4<br />
// @description	Applies darker stylesheets based on the presence of bright backgrounds and includes a day/night switch.<br />
// ==/UserScript==</p>
<pre><code>var bodyBackground = /*@Body background@string@*/'peachpuff'/*@*/;
var maxIterations = /*@Max iterations@int@*/50/*@*/;
var night = /*@Enable automatic night style@bool@*/false/*@*/;
var nightTime = [/*@_Night start (hours)@int@*/19/*@*/,
/*@_Night end (hours)@int@*/10/*@*/];
var thresHoldDay = /*@Brightness threshold day@int@*/245/*@*/;
var thresHoldNight = /*@Brightness threshold night@int@*/242/*@*/;
// from http://userstyles.org/styles/14836
var CSSDay = '\
</code></pre>
<p dir="auto">//	* {<br />
//		color: #000000 !important;<br />
//		<br />
//	}<br />
a {color: #0000F4;}<br />
li,html {<br />
background-color: #98FB98 !important;<br />
}<br />
body {<br />
background-color: peachpuff !important;<br />
}<br />
tr,td {<br />
background-color: #90D4FF !important;<br />
}<br />
div {<br />
background-color: #c0c0c0 !important;<br />
}<br />
pre,blockquote {<br />
background-color: yellow !important;<br />
}<br />
select, textarea,<br />
input[name=q], input[type=text], input[type=password], input[type=file] {<br />
background-color: #c6e6e6 !important;<br />
color: #222222 !important;<br />
border-color: #aaaaaa !important;<br />
border: 1px dotted #aaaaaa !important;<br />
}<br />
input[type=button], input[type=submit], input[type=reset] {<br />
background-color: #f3f3b3 !important;<br />
color: #222222 !important;<br />
border-color: #aaaaaa !important;<br />
}<br />
';</p>
<pre><code>function getRGBColor(node,prop)
{
	var rgb=getComputedStyle(node, null).getPropertyValue(prop);
	var r,g,b;
	
	if (node == document.documentElement &amp;&amp; rgb == 'transparent')
	{
		node.style.backgroundColor = bodyBackground;
		return false;
	}
	
	if (/#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})/.exec(rgb))
	{
		r=parseInt(RegExp.$1, 16);
		g=parseInt(RegExp.$2, 16);
		b=parseInt(RegExp.$3, 16);
		return [r, g, b];
	}
	
	return false;
}

function addStyle(type)
{
	var style = document.createElement('style');
	style.setAttribute('type', 'text/css');
	style.textContent = (type == 'night') ? CSSNight : CSSDay;
	//document.body.previousSibling.appendChild(style);// previousSibling might be a comment or something
	//document.getElementsByTagName('head')[0].appendChild(style);// valid, but might be superseded
	document.documentElement.appendChild(style);// not valid, but will supersede potential STYLE elements in document.body
}

function determineBrightness (color)
{
	if (color)
		return (color[0]*299 + color[1]*587 + color[2]*114) / 1000;
	else
		return false;
}
	
function adjustBrightness(brightness)
{
	if (night)
	{
		if ( ( hours &lt; nightTime[0] &amp;&amp; hours &gt;= nightTime[1] ) &amp;&amp; (brightness &gt; thresHoldDay)	)
		{
			addStyle('day');
			return true;
		}
		else if ( ( hours &gt;= nightTime[0] || hours &lt; nightTime[1] ) &amp;&amp; (brightness &gt; thresHoldNight) )
		{
			addStyle('night');
			return true;
		}
	}
	else if (brightness &gt; thresHoldDay)
	{
		addStyle('day');
		return true;
	}
	return false;
}

var allElem = document.getElementsByTagName('*');

for (
	var i=0;
	i&lt;allElem.length &amp;&amp; i&lt;maxIterations;// attempt not to impact performance too much vs. effectiveness
	i++
)
{
	var color = getRGBColor(allElem[i],'background-color');
	//opera.postError(i+'  rgb:'+color+' brightness:'+determineBrightness(color));
	if (color &amp;&amp; adjustBrightness(determineBrightness(color)))
	{
		break;
	}
}
</code></pre>
<p dir="auto">`</p>
]]></description><link>https://forums.opera.com/topic/19614/using-violentmonkey-scripts</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 19:59:55 GMT</lastBuildDate><atom:link href="https://forums.opera.com/topic/19614.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Mar 2017 17:34:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using Violentmonkey scripts on Mon, 17 Apr 2017 23:26:31 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">I can switch manually.</p>
</blockquote>
<p dir="auto">Yes, but it's a nice feature.</p>
]]></description><link>https://forums.opera.com/post/119000</link><guid isPermaLink="true">https://forums.opera.com/post/119000</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Mon, 17 Apr 2017 23:26:31 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Wed, 12 Apr 2017 18:53:43 GMT]]></title><description><![CDATA[<p dir="auto">I can switch manually.</p>
]]></description><link>https://forums.opera.com/post/118754</link><guid isPermaLink="true">https://forums.opera.com/post/118754</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Wed, 12 Apr 2017 18:53:43 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Wed, 12 Apr 2017 11:04:57 GMT]]></title><description><![CDATA[<p dir="auto">You may read the help file or open Opera before xD</p>
]]></description><link>https://forums.opera.com/post/118724</link><guid isPermaLink="true">https://forums.opera.com/post/118724</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Wed, 12 Apr 2017 11:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Tue, 11 Apr 2017 07:29:32 GMT]]></title><description><![CDATA[<p dir="auto">But it means that there cannot be a flag to tell it that the time to switch has passed already.</p>
]]></description><link>https://forums.opera.com/post/118648</link><guid isPermaLink="true">https://forums.opera.com/post/118648</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Tue, 11 Apr 2017 07:29:32 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Tue, 11 Apr 2017 05:08:53 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">Night Mode Pro just made a liar out of me.</p>
</blockquote>
<p dir="auto">:lol:<br />
Don't worry, sometimes trust in others could make us seem to be a liar.</p>
<blockquote>
<p dir="auto">Does Opera have to be running at the time for it to switch?</p>
</blockquote>
<p dir="auto">I suppose, since the extension works in Opera and don't have another process or service in the background to keep them alive.</p>
]]></description><link>https://forums.opera.com/post/118643</link><guid isPermaLink="true">https://forums.opera.com/post/118643</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Tue, 11 Apr 2017 05:08:53 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Sat, 08 Apr 2017 05:09:30 GMT]]></title><description><![CDATA[<p dir="auto">Night Mode Pro just made a liar out of me.  It switched modes.  Why did it not do that before?  Does Opera have to be running at the time for it to switch?</p>
]]></description><link>https://forums.opera.com/post/118481</link><guid isPermaLink="true">https://forums.opera.com/post/118481</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Sat, 08 Apr 2017 05:09:30 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Sat, 08 Apr 2017 05:08:35 GMT]]></title><description><![CDATA[<p dir="auto">Night Mode Pro just made a liar out of me.  It switched modes.  Why did it not do that before?</p>
]]></description><link>https://forums.opera.com/post/118480</link><guid isPermaLink="true">https://forums.opera.com/post/118480</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Sat, 08 Apr 2017 05:08:35 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Fri, 07 Apr 2017 20:52:18 GMT]]></title><description><![CDATA[<p dir="auto">AM and PM?  I thought that HH:MM meant 24-hour time.  That is what I use with the computer's operating system.</p>
<p dir="auto">I tried to submit a bug report, but <a href="http://mybrowseraddon.com" target="_blank" rel="noopener noreferrer nofollow ugc">mybrowseraddon.com</a> just gives an error message when I try.  I did allow it to set cookies, since I have seen problems with CAPTCHAs when cookies are blocked.  It does not matter what browser I use either.</p>
]]></description><link>https://forums.opera.com/post/118467</link><guid isPermaLink="true">https://forums.opera.com/post/118467</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Fri, 07 Apr 2017 20:52:18 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Thu, 06 Apr 2017 23:50:50 GMT]]></title><description><![CDATA[<p dir="auto">It works here, just play with the AM and PM.</p>
]]></description><link>https://forums.opera.com/post/118411</link><guid isPermaLink="true">https://forums.opera.com/post/118411</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Thu, 06 Apr 2017 23:50:50 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Thu, 06 Apr 2017 20:57:23 GMT]]></title><description><![CDATA[<p dir="auto">The issue with dimming things is solved.  I found another script for Violentmonkey that does dim overly light pages.</p>
<p dir="auto">Interestingly, with Night Mode Pro, I input a schedule to use for switching to night mode, but that does not work.  I can switch manually, though.</p>
]]></description><link>https://forums.opera.com/post/118389</link><guid isPermaLink="true">https://forums.opera.com/post/118389</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Thu, 06 Apr 2017 20:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Tue, 07 Mar 2017 23:26:46 GMT]]></title><description><![CDATA[<p dir="auto">:eek: Wow!<br />
I've give it a try and found a very welcome option, Schedule for the dark background!!<br />
I've used dark background styles long time ago and lately I was thinking about an automatic enable / disable depending on the time and this extension does the trick! <img src="https://forums.opera.com/assets/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ffrjq97ccbo" class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes" title=":-D" alt="😃" /></p>
<p dir="auto">Thanks for posting it!  :yes:<br />
<img src="https://forums.opera.com/assets/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f37a.png?v=ffrjq97ccbo" class="not-responsive emoji emoji-emoji-one emoji--beer_mug" title=":beer:" alt="🍺" />  :cheers:</p>
<p dir="auto">I have to test the schedule.</p>
]]></description><link>https://forums.opera.com/post/116453</link><guid isPermaLink="true">https://forums.opera.com/post/116453</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Tue, 07 Mar 2017 23:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Tue, 07 Mar 2017 19:19:13 GMT]]></title><description><![CDATA[<p dir="auto">Night Mode Pro extension dims things a bit, so that works.</p>
]]></description><link>https://forums.opera.com/post/116447</link><guid isPermaLink="true">https://forums.opera.com/post/116447</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Tue, 07 Mar 2017 19:19:13 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Tue, 07 Mar 2017 01:12:54 GMT]]></title><description><![CDATA[<p dir="auto">You may try Stylish and search in <a href="http://Userstyles.org" target="_blank" rel="noopener noreferrer nofollow ugc">Userstyles.org</a> "Global Dark" themes, they could be used as a Userscript too with Tamper / Violent Monkey extensions.</p>
]]></description><link>https://forums.opera.com/post/116378</link><guid isPermaLink="true">https://forums.opera.com/post/116378</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Tue, 07 Mar 2017 01:12:54 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Mon, 06 Mar 2017 23:51:26 GMT]]></title><description><![CDATA[<p dir="auto">I listed the whole thing, but it does not work.  It was originally a greasemonkey script, according to the person who got it for me.  I have a problem with white backgrounds, which is why I wanted to use it.  It worked fine with Presto Opera, but the structure of that was very different from the current Webkit Opera.</p>
<p dir="auto">I am now using a script which I modified to create yellow backgrounds if the background is too light.  The other one was nicer.  It could use a different background for different elements.  I do not know enough about javascript to specify the elements to change.</p>
]]></description><link>https://forums.opera.com/post/116375</link><guid isPermaLink="true">https://forums.opera.com/post/116375</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 06 Mar 2017 23:51:26 GMT</pubDate></item><item><title><![CDATA[Reply to Using Violentmonkey scripts on Mon, 06 Mar 2017 19:23:50 GMT]]></title><description><![CDATA[<p dir="auto">I would like try the script, should include?:</p>
<p dir="auto">// @include     http*</p>
]]></description><link>https://forums.opera.com/post/116353</link><guid isPermaLink="true">https://forums.opera.com/post/116353</guid><dc:creator><![CDATA[zalex108]]></dc:creator><pubDate>Mon, 06 Mar 2017 19:23:50 GMT</pubDate></item></channel></rss>