Changeset 18866 for lang/javascript/userscripts
- Timestamp:
- 09/05/08 02:05:59 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/customPalletForHaiku/trunk/customPalletForHaiku.user.js
r15669 r18866 3 3 // @namespace http://kojiran.googlepages.com/ 4 4 // @include http://h.hatena.ne.jp/* 5 // @include http://h.hatena.com/* 5 6 // @version 0.22 6 7 // … … 13 14 // ==/UserScript== 14 15 15 (function() {16 (function() { 16 17 17 18 if ( !(unsafeWindow && unsafeWindow.Hatena && unsafeWindow.Hatena.Star) ) … … 33 34 34 35 // 35 var Wedata = (function() {36 37 function getHatenaID () {36 var Wedata = (function() { 37 38 function getHatenaID () { 38 39 return unsafeWindow.Hatena.Visitor.name; 39 40 } … … 50 51 51 52 return { 52 fetch: function() {53 fetch: function() { 53 54 GM_xmlhttpRequest({ 54 55 method: 'GET', 55 url: WEDATA_FETCH,56 url: WEDATA_FETCH, 56 57 onload: function(res) { 57 if ( res.status != 200 ) {58 if ( res.status != 200 ) { 58 59 alert('something wrong...' + 59 60 res.status + … … 67 68 if (!( items instanceof Array )) throw new Error; 68 69 var dic = {}; 69 items.forEach( function(item) {70 items.forEach( function(item) { 70 71 dic[item.name] = item.data.colors.split(/\s+/); 71 72 }); … … 84 85 }, 85 86 86 fix: function( name, pallet ) {87 if ( !confirm('really ??') ) return;87 fix: function( name, pallet ) { 88 if ( !confirm('really ??') ) return; 88 89 var data = { name: name , data: { colors: pallet } }; 89 90 if ( unsafeWindow.CustomPalletForHaikuPallets[name] instanceof Array ) { … … 98 99 function getCookie(key) { 99 100 var re = new RegExp(key + "=([^;]+)", "i"); 100 document.cookie.match(re); 101 102 return(RegExp.$1 ? unescape(RegExp.$1) : ""); 101 102 return(re.test(document.cookie) ? unescape(RegExp.$1) : ""); 103 103 } 104 104 … … 109 109 // But work with real window object. 110 110 location.href = 'javascript:(' + function() { 111 (function (w) {111 (function(w) { 112 112 113 113 function log () { … … 118 118 } 119 119 120 function delayUntill( cond, action , max ) {121 setTimeout( function() {120 function delayUntill( cond, action , max ) { 121 setTimeout( function() { 122 122 if ( cond() ) { 123 123 action(); 124 } else if ( max > 0 ) {124 } else if ( max > 0 ) { 125 125 delayUntill( cond , action , max - 1 ); 126 126 } … … 129 129 130 130 // initialize ... 131 function initSelector() {131 function initSelector() { 132 132 var entryForm = $X('.//form[@class="entry-form"]')[0]; 133 133 var textContainer = $X('div[@class="text-container"]', entryForm)[0]; 134 var colors = $N('span', {style: ["margin: 5px 5px"].join(';'),134 var colors = $N('span', {style: "margin: 5px", 135 135 id: 'pallet-colors'}); 136 var changer = function () {136 var changer = function() { 137 137 for (var i = 0, l = colors.childNodes.length; i < l; i++) { 138 138 colors.removeChild(colors.firstChild); 139 139 } 140 CustomPalletForHaikuPallets[select.value].forEach(function (color) {140 CustomPalletForHaikuPallets[select.value].forEach(function(color) { 141 141 var cell = $N('span', {style: [ 142 142 "background: #" + color, … … 163 163 var $E = Ten.DOM.getElementsByTagAndClassName; 164 164 var textSelector = $E('img', 'input-selector-text')[0]; 165 new Ten.Observer(textSelector, 'onclick', function () {165 new Ten.Observer(textSelector, 'onclick', function() { 166 166 select.style.display = 'inline'; 167 167 colors.style.display = 'inline'; 168 168 }); 169 169 var drawSelector = $E('img', 'input-selector-draw')[0]; 170 new Ten.Observer(drawSelector, 'onclick', function () {170 new Ten.Observer(drawSelector, 'onclick', function() { 171 171 select.style.display = 'none'; 172 172 colors.style.display = 'none'; 173 173 }); 174 174 var webcamSelector = $E('img', 'input-selector-webcam')[0]; 175 new Ten.Observer(webcamSelector, 'onclick', function () {175 new Ten.Observer(webcamSelector, 'onclick', function() { 176 176 select.style.display = 'none'; 177 177 colors.style.display = 'none'; … … 185 185 SWFObject.prototype = deconcept.SWFObject.prototype; 186 186 187 (function(orig) {188 Hatena.Haiku.EntryForm.prototype.writeDrawForm = function() {189 if ( this.canvas ) {187 (function(orig) { 188 Hatena.Haiku.EntryForm.prototype.writeDrawForm = function() { 189 if ( this.canvas ) { 190 190 var canvas = this.canvas; 191 191 var swf = canvas.getSWF(); … … 204 204 } 205 205 206 delayUntill( function() { return CustomPalletForHaikuPallets } ,206 delayUntill( function() { return CustomPalletForHaikuPallets } , 207 207 initSelector, 100 ); 208 208 … … 217 217 else ret.setAttribute(k, v); 218 218 } 219 switch (typeof childs){219 switch (typeof childs) { 220 220 case "string": 221 221 ret.appendChild(document.createTextNode(childs)); … … 246 246 var type, namespace={}; 247 247 // console.log(String(exp)); 248 if (typeof context == "function"){248 if (typeof context == "function") { 249 249 type = context; 250 250 context = null; 251 } else if(typeof context != "undefined" && !context['nodeType']){251 } else if (typeof context != "undefined" && !context['nodeType']) { 252 252 type = context['type']; 253 253 namespace = context['namespace'] || context['ns']; … … 256 256 257 257 if (!context) context = document; 258 var exp = (context.ownerDocument || context).createExpression(exp, function (prefix) {258 var exp = (context.ownerDocument || context).createExpression(exp, function(prefix) { 259 259 return namespace[prefix] || 260 260 document.createNSResolver((context.ownerDocument == null ? context : context.ownerDocument)
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)