Greasemonkey und QuickEdit! Super Script.
Habe jetzt stundenlang gesucht und probiert. Leider ohne Ergebniss.
Ich hätte gerne statt dem Text "[ EQ ]" eine Grafik.
Hab es auch mittlerweile geschafft eine Grafik einzubinden.
Wenn ich aber auf diese klicke - passiert nix.
Was muss ich noch beachten?!
Hier der (von mir veränderte) Script:
Code
// ==/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);
}
Alles anzeigen
Bitte um Hilfe! Danke!