User:GeorgeMoney/UserScripts/savecookie

//

//

//COOKIE SAVING

function changemsg(msg,color) {
if(!color) {
var color = 'green';
}
var txtr = "editsts";
var div = document.getElementById(txtr);
div.innerHTML = '<div style="font-weight:bold; font-size:bigger;border:3px solid '+color+';background:honeydew;padding:3px;"><font color="'+color+'">'+msg+'</font></div>';

}

if (window.location.href.indexOf('action=edit') != -1 || window.location.href.indexOf('action=submit') != -1) {

addOnloadHook(function(){

s='<input id="wpSave" name="wpSave" type="submit" tabindex="5" value="Save page" accesskey="s" title="Save your changes [alt-s]" />\n<input id="wpPreview" name="wpPreview" type="submit" tabindex="6" value="Show preview" accesskey="p" title="Preview your changes, please use this before saving! [alt-p]" />\n<input id="wpDiff" name="wpDiff" type="submit" tabindex="7" value="Show changes" accesskey="v" title="Show which changes you made to the text. [alt-v]" />\n<br>';
s+='<input type="button" onclick="if(escape(document.getElementById(\'wpTextbox1\').value).length > 4038) { changemsg(\'Cannot save to cookie. Reason: Page size too large to be saved in cookie, sorry! It must be below 4038 characters in length, and your text is \'+escape(document.getElementById(\'wpTextbox1\').value).length+\' characters, which is \'+ (escape(document.getElementById(\'wpTextbox1\').value).length - 4038) + \' characters too many!\', \'red\'); alert(\'Error! Page size too large to be saved in cookie, sorry! It must be below 4038 characters in length, and your text is \'+escape(document.getElementById(\'wpTextbox1\').value).length+\' characters, which is \'+ (escape(document.getElementById(\'wpTextbox1\').value).length - 4038) + \' characters too many! \');  } else { createCookie(\'SAVEDWIKIPAGE-'+wgPageName+'\', escape(document.getElementById(\'wpTextbox1\').value), 365); changemsg(\'Cookie saved!\'); }" value="save to cookie" />  \n';
s+='<input type="button" onclick="var gh = unescape(readCookie(\'SAVEDWIKIPAGE-\'+document.getElementById(\'cookform\').value.replace(/\\s/g, \'_\'))); if(gh !== \'null\') { document.getElementById(\'wpTextbox1\').value = gh; changemsg(\'Cookie from page \'+document.getElementById(\'cookform\').value+\' successfully loaded into Edit Box\'); } else { changemsg(\'No cookie exists from page \'+document.getElementById(\'cookform\').value+\' \', \'red\'); }" value="load from cookie:" /><input type="button" onclick="eraseCookie(\'SAVEDWIKIPAGE-\'+document.getElementById(\'cookform\').value.replace(/\\s/g, \'_\')); changemsg(\'Cookie from page \'+document.getElementById(\'cookform\').value+\' deleted\');" value="delete cookie" />';
s+='<input type="text" value="'+wgPageName.replace(/\_/g, ' ')+'" id="cookform" size="40" />\n';
s+=' <input type="button" value="show all cookies" onclick="alert(document.cookie); changemsg(\'Cookies: \'+document.cookie);" /><input type="button" value="count characters" onclick="if(escape(document.getElementById(\'wpTextbox1\').value).length > 4038) { var extra = \'Which is too large to save into a cookie. Cookies can only handle 4038 characters. You have \' + (escape(document.getElementById(\'wpTextbox1\').value).length - 4038) + \' characters more than the limit. \'; } else { var extra = \'\'; } var msg = \'Characters in editbox (after converted to cookie encoded form): \'+ escape(document.getElementById(\'wpTextbox1\').value).length + \' characters. \'+extra; changemsg(msg); " />\n';
s+='<br><div id="editsts"> </div>\n';
    var divs = document.getElementsByTagName('div');
    for (i=0; i<divs.length; i++) {
	   if (divs[i].className == 'editButtons') {
	     divs[i].innerHTML = s;
	   }
	}

});

}

//END

//

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.