Seite 4 von 7

Verfasst: 30.12.2006, 18:03
von DasIch
Ich hab mal einen Comment auf der Website hinterlassen vielleicht bringt mich das weiter.

Verfasst: 30.12.2006, 18:33
von nik
DasIch hat geschrieben:Ich hab mal einen Comment auf der Website hinterlassen vielleicht bringt mich das weiter.
Wo?! :megaverbluefft:

Verfasst: 30.12.2006, 19:15
von r4ffi
jetzt gehts :) hatte fälschlicherweise garkeit firefox 2.0 installiert sondern 1.07... danke!


//edit: test test :)



Testweise
hier eingebrochen und mal mit der Formatierung gespielt!

Gruß Eumel ;)

Verfasst: 30.12.2006, 19:26
von Eumel
@ Raffi
Wollte mal sehen ob die Formatierungsbefehle funktionieren und muß sagen, paßt bestens. Wenn jetzt das [QE] nicht so bescheiden aussehen würde, wäre das Script ne nützliche Sache.

Verfasst: 30.12.2006, 20:01
von doneld
Das Problem der Funktion zur Linkerstellung des Skriptes ist, dass diese nicht mit Grafiken umgehen kann. Ein Bild einzubinden ist kein Problem. Das erledigt man in ner Minute. Aber ich werd morgen nochmal in der Funktion schauen...

MfG doneld

Verfasst: 30.12.2006, 22:03
von nik
Das hab ich auch gemerkt ... -.-

// boom - 1000ster Beitrag o.O //

Verfasst: 30.12.2006, 22:06
von DasIch
Das Bild hab ich hinbekommen aber den Rest Check ich nicht.

Offtopic: Greetz zum Desktop-King ;)

Verfasst: 30.12.2006, 22:08
von nik
Postet doch bitte eure (fertigen) Scripte, vielleicht kann der eine oder andere was daraus gebrauchen!

Verfasst: 30.12.2006, 22:13
von DasIch
Ich hab den Pfad geändert und die Angabe zur Text Größe gelöscht. Der Rest besteht für mich aus Hieroglyphen.

Verfasst: 30.12.2006, 22:13
von nik
Welchen Pfad?! o.O

Verfasst: 30.12.2006, 22:16
von DasIch
Also anstatt "[ QE ]" hab ich das Bild dingens da gemacht.

Verfasst: 30.12.2006, 22:18
von nik
aha?! :/

Poste mal bitte den Script.

Hier ist meiner:

Code: Alles auswählen

// ==/UserScript==

var Grafik1 =('<img src=\"http://img2.myimg.de/iconedithe51.gif\">');

function encodeFormData(formData){
   var encodedData = '';
   var t;
   for(i = 0; i < formData.length; i++){
      t = '' + formData.charCodeAt(i).toString(16).toUpperCase();
      if(t.length == 1)
         encodedData += "%0" + formData.charCodeAt(i).toString(16).toUpperCase();
      else
         encodedData += "%" + formData.charCodeAt(i).toString(16).toUpperCase();
   }
   return encodedData;
}

var addQuickEdit = function(event){
   var editHREF = event.target.previousSibling.href;
   var editHREFPart = editHREF.substring(editHREF.indexOf("posting.php"), editHREF.length);
   var postBody = document.evaluate("//a[@href='" + editHREFPart + "']/../../..//*[@class='postbody']/..", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
   postBody = postBody.snapshotItem(0);
   if(postBody.getElementsByTagName('textarea').length == 0){
      var allElements = postBody.getElementsByTagName('*');
      for(j = 0; j < allElements.length; j++)
         allElements[j].style.display = 'none';
      
      var qeTextArea = document.createElement('textarea');
      var qeSubmit = document.createElement('input');
      var qeIFrame = document.createElement("iframe");
      
      qeTextArea.style.width = '90%';
      qeTextArea.style.height = '200px';
      qeTextArea.style.border = '1px solid #000000';
      qeTextArea.style.paddingLeft = '2px';
      qeTextArea.style.paddingBottom = '2px';
      qeTextArea.value = '\n\n\n\n\n\t\t\tGetting post contents...';
      
      qeSubmit.type = 'submit';
      qeSubmit.value = 'Post';
      qeSubmit.style.border = '1px solid #000000';
      qeSubmit.style.position = 'absolute';
      qeSubmit.addEventListener('click', editPost, true);
      qeSubmit.setAttribute('editHREF', editHREF);

      qeIFrame.style.width = '1px';
      qeIFrame.style.height = '1px';
      qeIFrame.style.display = 'none';
      qeIFrame.src = editHREF;
      qeIFrame.addEventListener('load',
         function(){
            var qeDoc = qeIFrame.contentDocument;
            if(qeDoc.body.getElementsByTagName('textarea').length != 0){
               qeTextArea.value = qeDoc.body.getElementsByTagName('textarea')[0].value;
               qeDoc = qeDoc.getElementsByTagName('input');
               var formData = '';
               for(var i = 0; i < qeDoc.length; i++)
                  if(qeDoc[i].name.indexOf('addbbcode') == -1 && qeDoc[i].name.indexOf('helpbox') == -1 && qeDoc[i].name != '')
                     if(qeDoc[i].type != 'checkbox' || qeDoc[i].checked != '')
                        formData += qeDoc[i].name + '=' + encodeFormData(qeDoc[i].value) + '&';
               qeSubmit.setAttribute('formData', formData);
               qeDoc = null;
            } else {
               qeTextArea.value = '\n\n\n\n\n\t\t\tGetting post contents failed, refresh the page and try again.';
            }
         },
         false);
      
      postBody.insertBefore(qeSubmit, postBody.firstChild);
      postBody.insertBefore(qeTextArea, postBody.firstChild);
      document.body.appendChild(qeIFrame);
   } else {
      var allElements = postBody.getElementsByTagName('*');
      for(i = 0; i < allElements.length; i++)
         if(allElements[i].style.display == 'none')
            allElements[i].style.display = '';
         else
            allElements[i].style.display  = 'none';
   }
   event.preventDefault();
};

var editPost = function(event){
   var editHREF = event.target.getAttribute('editHREF').split('?')[0];
   var formData = event.target.getAttribute('formData');
   var postContents = encodeFormData(event.target.previousSibling.value);
   event.target.value = 'Speicherung...'
   GM_xmlhttpRequest({
      method: 'POST',
      url: editHREF,
      data: formData + 'message=' + postContents,
      headers: {'Content-Type': 'application/x-www-form-urlencoded'},
      onload: function(responseDetails) {
         window.location.reload(false);
      }
   });
};

var editLinks = document.evaluate("//a[contains(@href, 'posting.php?mode=editpost')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i = 0; i < editLinks.snapshotLength; i++){
   var qeLink = document.createElement('b');
   qeLink.setAttribute('title', "click to edit this post");
   qeLink.style.fontSize = "7pt";
   qeLink.style.cursor = 'pointer';
   qeLink.addEventListener('click', addQuickEdit, false);
   qeLink.innerHTML = Grafik1;
   editLinks.snapshotItem(i).parentNode.insertBefore(qeLink, editLinks.snapshotItem(i).nextSibling);
} 

Verfasst: 30.12.2006, 22:22
von DasIch
Hier ist meins 8) :

Code: Alles auswählen

// phpBB Quick Edit user script
// version 0.2
// 2006-03-12
// Copyright (c) 2006, xamm
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "phpBB Quick Edit", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ChangeLog
// 2006-03-12 - 0.2 - Fixed the code for encoding the form data that was corrupted by GM downloading it which I'd never known before
//                    which means my quick reply script has been broken for months and I never knew.
// 2006-03-12 - 0.1 - Initial release
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name           phpBB Quick Edit
// @namespace      http://www.otsegolectric.com/greasemonkey/
// @description    Adds a feature allowing you to quickly edit your posts on a phpBB forum
// @include        */viewtopic.php*
// ==/UserScript==

function encodeFormData(formData){ 
	var encodedData = ''; 
	var t;
	for(i = 0; i < formData.length; i++){
		t = '' + formData.charCodeAt(i).toString(16).toUpperCase();
		if(t.length == 1)
			encodedData += "%0" + formData.charCodeAt(i).toString(16).toUpperCase(); 
		else
			encodedData += "%" + formData.charCodeAt(i).toString(16).toUpperCase();
	}
	return encodedData;
} 

var addQuickEdit = function(event){
	var editHREF = event.target.previousSibling.href;
	var editHREFPart = editHREF.substring(editHREF.indexOf("posting.php"), editHREF.length);
	var postBody = document.evaluate("//a[@href='" + editHREFPart + "']/../../..//*[@class='postbody']/..", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	postBody = postBody.snapshotItem(0);
	if(postBody.getElementsByTagName('textarea').length == 0){
		var allElements = postBody.getElementsByTagName('*');
		for(j = 0; j < allElements.length; j++)
			allElements[j].style.display = 'none';
		
		var qeTextArea = document.createElement('textarea');
		var qeSubmit = document.createElement('input');
		var qeIFrame = document.createElement("iframe");
		
		qeTextArea.style.width = '90%';
		qeTextArea.style.height = '200px';
		qeTextArea.style.border = '1px solid #000000';
		qeTextArea.style.paddingLeft = '2px';
		qeTextArea.style.paddingBottom = '2px';
		qeTextArea.value = '\n\n\n\n\n\t\t\tGetting post contents...';
		
		qeSubmit.type = 'submit';
		qeSubmit.value = 'Post';
		qeSubmit.style.border = '1px solid #000000';
		qeSubmit.style.position = 'absolute';
		qeSubmit.addEventListener('click', editPost, true);
		qeSubmit.setAttribute('editHREF', editHREF);

		qeIFrame.style.width = '1px';
		qeIFrame.style.height = '1px';
		qeIFrame.style.display = 'none';
		qeIFrame.src = editHREF;
		qeIFrame.addEventListener('load',
			function(){
				var qeDoc = qeIFrame.contentDocument;
				if(qeDoc.body.getElementsByTagName('textarea').length != 0){
					qeTextArea.value = qeDoc.body.getElementsByTagName('textarea')[0].value;
					qeDoc = qeDoc.getElementsByTagName('input');
					var formData = '';
					for(var i = 0; i < qeDoc.length; i++)
						if(qeDoc[i].name.indexOf('addbbcode') == -1 && qeDoc[i].name.indexOf('helpbox') == -1 && qeDoc[i].name != '')
							if(qeDoc[i].type != 'checkbox' || qeDoc[i].checked != '')
								formData += qeDoc[i].name + '=' + encodeFormData(qeDoc[i].value) + '&';
					qeSubmit.setAttribute('formData', formData);
					qeDoc = null;
				} else {
					qeTextArea.value = '\n\n\n\n\n\t\t\tGetting post contents failed, refresh the page and try again.';
				}
			},
			false);
		
		postBody.insertBefore(qeSubmit, postBody.firstChild);
		postBody.insertBefore(qeTextArea, postBody.firstChild);
		document.body.appendChild(qeIFrame);
	} else {
		var allElements = postBody.getElementsByTagName('*');
		for(i = 0; i < allElements.length; i++)
			if(allElements[i].style.display == 'none')
				allElements[i].style.display = '';
			else
				allElements[i].style.display  = 'none';
	}
	event.preventDefault();
};

var editPost = function(event){
	var editHREF = event.target.getAttribute('editHREF').split('?')[0];
	var formData = event.target.getAttribute('formData');
	var postContents = encodeFormData(event.target.previousSibling.value);
	event.target.value = 'Submitting...'
	GM_xmlhttpRequest({
		method: 'POST',
		url: editHREF,
		data: formData + 'message=' + postContents,
		headers: {'Content-Type': 'application/x-www-form-urlencoded'},
		onload: function(responseDetails) {
			window.location.reload(false);
		}
	});
};

var editLinks = document.evaluate("//a[contains(@href, 'posting.php?mode=editpost')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for(var i = 0; i < editLinks.snapshotLength; i++){
	var qeLink = document.createElement('b');
	qeLink.setAttribute('title', "quick edit");
	qeLink.style.cursor = 'pointer';
	qeLink.addEventListener('click', addQuickEdit, true);
	qeLink.innerHTML = '<img src=http://www.deskmodder.de/phpBB2/images/icon_edit.gif>';
	editLinks.snapshotItem(i).parentNode.insertBefore(qeLink, editLinks.snapshotItem(i).nextSibling);
}
Jaja das mit dem Bild hab ich mir einfacher gemacht :D

Verfasst: 30.12.2006, 22:26
von nik
Und das geht bei dir, so wie du's gemacht hast?! :/

Verfasst: 30.12.2006, 22:31
von DasIch
Naja das Bild ist da aber der Rest...