Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setCookie(cname, cvalue, exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
- var expires = "expires="+d.toUTCString();
- document.cookie = cname + "=" + cvalue + "; " + expires;
- } ;
- function getCookie(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for(var i=0; i<ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1);
- if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
- }
- return "";
- } ;
- (function(ext) {
- // Cleanup function when the extension is unloaded
- ext._shutdown = function() {};
- // Status reporting code
- // Use this to report missing hardware, plugin or unsupported browser
- ext._getStatus = function() {
- return {status: 2, msg: 'Ready'};
- };
- ext.save = function(thing, cookie){
- setCookie(cookie, thing, 99999999999999);
- };
- ext.read = function(that){
- return getCookie(that);
- };
- ext.delete = function(cookie){
- setCookie(cookie, '12', -10);
- };
- ext.installed = function(){
- var foo = true;
- return foo;
- };
- // Block and block menu descriptions
- var descriptor = {
- blocks: [
- [' ', 'save %s to cookie %s', 'save', 'thing', 'cookie1'],
- ['r', 'read cookie %s', 'read', 'cookie1'],
- [' ', 'delete cookie %s', 'delete', 'cookie1'],
- ['b', 'installed?', 'installed'],
- ],
- url: 'http://scratch.mit.edu/projects/40581194/'
- };
- // Register the extension
- ScratchExtensions.register('Cookies', descriptor, ext);
- })({});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement