Показать сообщение отдельно
  #1 (permalink)  
Старый 20.07.2012, 14:35
Новичок на форуме
Отправить личное сообщение для Wald Посмотреть профиль Найти все сообщения от Wald
 
Регистрация: 12.06.2012
Сообщений: 6

Из XML Javascript
Для Maxthon 2 есть фильтр, каторый хотелось бы сделать в виде Javascript.
Перепробывал многое методом тыка. Ничего не получилось... Может кто поможет...
<m2filter version="1.0">
	<package author="Artyom Shegeda" description="Highlights users online" title="RU-Board Whos Online" support_url="http://forum.ru-board.com/" version="0.0.4"/>
	<filterlist>
		<filter enable="1" name="whos online ajax" author="Artyom Shegeda" type="text" comment="" action="3" priority="0" match="&lt;\/head&gt;" match_count="1" replace="&lt;script type=&quot;text/javascript&quot;&gt;
this.whosonline = ({
	autoHighlight: false,
	url: '/whosonline.cgi',
	load: function() {
		if (this.xmlHttp)
			return;
		try
		{
			this.xmlHttp=new XMLHttpRequest()
			if (this.xmlHttp.overrideMimeType &amp;&amp; this.method=='POST') this.xmlHttp.overrideMimeType('text/html')
		}
		catch (e)
		{
			var msv=[&quot;Msxml2.XMLHTTP.7.0&quot;, &quot;Msxml2.XMLHTTP.6.0&quot;, &quot;Msxml2.XMLHTTP.5.0&quot;, &quot;Msxml2.XMLHTTP.4.0&quot;, &quot;MSXML2.XMLHTTP.3.0&quot;, &quot;MSXML2.XMLHTTP&quot;, &quot;Microsoft.XMLHTTP&quot;]
			for(var j=0;j&lt;=msv.length;j++)
			{
				try 
				{ 
					this.xmlHttp=new ActiveXObject(msv[j])
					break
				} 
				catch(e){ } 
			} 
			if (!this.xmlHttp) return false    
		}
		var self = this
		this.xmlHttp.onreadystatechange=function()
		{
			if(self.xmlHttp.readyState==4)
			{
				self.processResponse(self.xmlHttp.responseText)
				self.xmlHttp = null;
			}
		}
		this.xmlHttp.open(&quot;GET&quot;,this.url+'?timestamp='+Math.floor(new Date().valueOf()/60000),true);
		this.xmlHttp.send(null);
	},
	processResponse: function(text) {
		var users = {};
		text.replace(/&lt;a href=&quot;profile\\.cgi\\?action=show&amp;member=.*?&quot;&gt;(.*?)&lt;\\/a&gt;/g, function(a,b){
			users[b]=true;
		});
		this.users = users;
		this.autoHighlight &amp;&amp; this.highlightUsers();
	},
	highlightUsers: function() {
		if (!this.users) {
			this.autoHighlight = true;
			if (!this.xmlHttp) {
				this.load();
			}
			return;
		}
		try {
			var elements = document.getElementsByTagName('B');
			for(var i=0; i&lt;elements.length; i++) {
				if (elements[i].parentNode.className=='m' &amp;&amp; this.users[elements[i].innerText]) {
					var onlinestatus = document.createElement('div');
					onlinestatus.style.display='inline';
					onlinestatus.style.width='10px';
					onlinestatus.style.height='10px';
					onlinestatus.style.lineHeight='10px';
					onlinestatus.style.background='#80FF80';
					onlinestatus.style.borderTop='1px solid #c0ffc0';
					onlinestatus.style.borderLeft='1px solid #c0ffc0';
					onlinestatus.style.borderRight='1px solid #60bf60';
					onlinestatus.style.borderBottom='1px solid #60bf60';
					onlinestatus.style.marginRight='5px';
					onlinestatus.title='User online';
					elements[i].parentNode.insertBefore(onlinestatus,elements[i]);
				}
			}
		} catch(e) {
			alert(e.message);
		}
	},
	createHighlightButton: function() {
		var node = document.forms['postform'].parentNode;
		var button = document.createElement('button');
		button.innerText = 'Показать, кто онлайн';
		button.style.margin = '10px 0 0 40px'
		var self = this;
		button.onclick = function(){
			if (!self.users) {
				self.autoHighlight = true;
				self.load();
			}
		}
		node.parentNode.insertBefore(button, node);
	},
	run: function() {
		return this;
	}
}).run();
&lt;/script&gt;
&lt;/head&gt;" match_url="^http\:\/\/forum\.ru-board\.com\/topic\.cgi" exclude_url="" bound="" max_bound_size="0" exclude="" keywords=""/><filter name="auto highlight" author="Artyom Shegeda" type="text" comment="" action="3" priority="0" match="(&lt;body\s)" match_count="1" replace="&lt;script type=&quot;text/javascript&quot;&gt;
whosonline&amp;&amp;(whosonline.load(),window.onload=function(){whosonline.highlightUsers();});
&lt;/script&gt;
$1" match_url="^http\:\/\/forum\.ru-board\.com\/topic\.cgi" exclude_url="" bound="" max_bound_size="0" exclude="" keywords="" enable="1"/><filter name="whos online button" author="Artyom Shegeda" type="text" comment="" action="3" priority="0" match="&lt;\/body&gt;" match_count="1" replace="&lt;/body&gt;&lt;script type=&quot;text/javascript&quot;&gt;
whosonline&amp;&amp;whosonline.createHighlightButton();
&lt;/script&gt;" match_url="^http\:\/\/forum\.ru-board\.com\/topic\.cgi" exclude_url="" bound="" max_bound_size="0" exclude="" keywords="" enable="1"/></filterlist>
</m2filter>
Ответить с цитированием