Inline Edit GM script not working... - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: General (/forumdisplay.php?fid=11)
+---- Forum: Forum & Website (/forumdisplay.php?fid=13)
+----- Thread: Inline Edit GM script not working... (/showthread.php?tid=94262)
Inline Edit GM script not working... by matty on 03-31-2010 at 06:30 PM
When trying to use the following script I get a Security error... WDZ any idea why?
js code: // ==UserScript==
// @name MsgHelp.net - inline.editing
// @namespace http://*msghelp.net/*
// @include http://*msghelp.net/*
// ==/UserScript==
var url = 'http://shoutbox.menthix.net/editpost.php';
var pid;
var postkey;
var subject;
if ( typeof unsafeWindow !== 'object' ) {
unsafeWindow = window;
}
var iEdit = document.createElement ( 'img' );
iEdit.setAttribute ( 'src' , 'data:image/gif;base64,R0lGODlhOQAPAPcAAAAAAGtzayFShCFahCFajClajDFjjDFjlDljlDlrlDlrnCFjrSlrrSFrtSFrvSlztSlzvUJrjEprjEJrlEprlEJznEpznFJznEJ7rVJ7pVp7pVKEpVqEpVqErWuElHOMnGOEpWSDqmOMrWuMrXucrXuUtXuctVqt72Oczmul3mu153u153u195xKMYxSUqVza4x7hIycrYSctZycpYSltYSlvYylvZSlrZStvZyttaWtra2trbW9vb29tYStzoytzpStxpytxpS1zpy1xpy9zpy91py93oy99629xq29zoTO/63O1rXGzrXG1rXO1r3G1r3O1qXO563O56XO963W563W973n/87GvcbGxsbO1sbO3sbW3s7W3s7e3t7Wzt7eztbW1tbe3t7e1t7e3s7e59be597e587n987n/87v/97n597n797v997v/+fe1ufn1ufn3u/n1u/n3ufn5+fv5+fv7+/v5+/v7+/v9+/37+f3/+/39+/3/+////f37/f39/f/9//39///9////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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BHkquuuvPbaK66+BourAgssZOyxyC4UEAA7' );
var iLoading = unsafeWindow.document.createElement ( 'img' );
iLoading.setAttribute ( 'src' , 'data:image/gif;base64,R0lGODlhIAAgAPMAAP///wAAAMbGxoSEhLa2tpqamjY2NlZWVtjY2OTk5Ly8vB4eHgQEBAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQJCgAAACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQJCgAAACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJColTMANldx15BGs8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dCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA' );
iLoading.setAttribute ( 'style', 'display: block; margin: 0 auto; padding: 1em 0' );
var oDivLoading = document.createElement ( 'div' );
oDivLoading.setAttribute ( 'style' , 'margin: 10px auto;' );
var paragraph = document.createElement ( 'p' );
paragraph.style.textAlign = "center";
paragraph.appendChild( iLoading );
paragraph.appendChild( document.createTextNode( 'Loading inline editor...' ) );
oDivLoading.appendChild( paragraph );
var x = document.getElementsByTagName("A");
var elem, match;
for ( var i in x ) {
var h = x[i].href;
// Look for an anchor that links to editpost.php
if ( match = h.match(/editpost\.php\?pid=([0-9]+)$/) ) {
pid = match[1];
elem = x[i];
// Add an inline edit button
var button = iEdit.cloneNode( false );
button.addEventListener( 'click' , createListener( pid ), false );
elem.parentNode.insertBefore ( button , elem );
}
}
// Creates an event listener for the inline edit button
function createListener( pid ) {
var args = arguments;
return function() {
// Call inlineEditor(pid) when clicked
unsafeWindow.inlineEditor.apply(null, args);
};
}
function createInlineEditor(pid) {
// Prepare some DIVs to hold the inline editor
var tDiv = getId ( 'pid_'+pid );
var oDiv = oDivLoading.cloneNode( true );
oDiv.setAttribute( 'id', 'pid_inline_'+pid);
tDiv.parentNode.insertBefore ( oDiv, tDiv );
tDiv.style.display = 'none';
//Start an XML HTTP Request for editpost.php
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', url+'?pid='+pid, true);
xmlhttp.onreadystatechange = function () {
if ( xmlhttp.readyState !== 4 ) return;
// Get the post_key and subject values
var match = xmlhttp.responseText.match(/name="post_key" value="([a-f0-9]+)"/);
if(match) {
postkey = match[1]; // All OK
}
match = xmlhttp.responseText.match(/name="subject" (.*) value="?(.*)"/);
if(match) {
subject = match[2].split('"')[0]; // All OK
}
if ( postkey !== 'undefined' && subject !== 'undefined' ) {
// Set the editor content
oDiv.innerHTML = '<form action="editpost.php" method="POST" enctype="multipart/form-data" name="input">'+
'<input type="hidden" name="subject" size="50" maxlength="85" value="'+subject+'" tabindex="1" />'+
'<input type="hidden" name="action" value="do_editpost" />'+
'<input type="hidden" name="pid" value="'+pid+'" />'+
'<input type="hidden" name="post_key" value="'+postkey+'" />'+
'<input type="hidden" name="postoptions[isset]" value="1" />'+
'<textarea name="message" rows="10" cols="100" wrap="virtual" tabindex="3">'+getId ('qqmsg'+pid).value+'</textarea>'+
'<br /><br /><input type="submit" value="Update Post" />'+
'<input type="button" value="Cancel Update" onClick="javascript:inlineEditor('+pid+');" /></form>';
}
else inlineEditor ( pid );
}
xmlhttp.send( null );
}
unsafeWindow.inlineEditor = function ( pid ) {
// Create an inline editor if not available yet
var obj = getId ( 'pid_inline_'+pid );
if (obj === null) return createInlineEditor( pid );
// Swap the editor style between visible and hidden
if ( obj.style.display === 'none' ) { obj.style.display = ''; }
else { obj.style.display = 'none'; }
// Swap the post body style between visible and hidden
obj = getId ( 'pid_'+pid );
if ( obj.style.display === '' ) { obj.style.display = 'none'; }
else { obj.style.display = ''; }
}
function getId ( id ) { return document.getElementById ( id ); }
RE: Inline Edit GM script not working... by WDZ on 03-31-2010 at 08:10 PM
I don't feel like debugging it at the moment, but this version works fine AFAIK.
RE: Inline Edit GM script not working... by Chrissy on 03-31-2010 at 08:28 PM
quote: Originally posted by WDZ
I don't feel like debugging it at the moment, but this version works fine AFAIK.
I'm using that one and it's fine
RE: Inline Edit GM script not working... by andrey on 03-31-2010 at 09:30 PM
quote: Originally posted by matty
When trying to use the following script I get a Security error... WDZ any idea why?
seems to work for me
but yeah, dz's script works fine as well..
|