Changeset 31076
- Timestamp:
- 03/12/09 01:47:40 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/easy_im_reading_now_isgd.user.js
r31075 r31076 3 3 // @namespace http://mirupreza.tumblr.com/ 4 4 // @description Usage: Ctrl + Shift + Enter -> "Browsing: ****" on Twitter! 5 // @include * 6 // @version 0.0.1 5 // @include http://* 6 // @include https://* 7 // @version 0.0.2 7 8 // ==/UserScript== 8 9 // 9 // last modified: 2009/03/1 101:2010 // 10 // last modified: 2009/03/12 01:20 11 // 11 12 12 13 13 (function (){14 (function() { 14 15 15 16 // --- user customize start --- 16 17 17 var use TinyURL= true18 var useIsgd = true 18 19 var useAlert = false 19 var defaultTag = "\u898B\u3066\u308B:"20 var defaultTag = '\u898B\u3066\u308B:' 20 21 var replaceTag = true 21 22 … … 25 26 var w = window 26 27 if (typeof unsafeWindow != 'undefined') { w = unsafeWindow } 27 function debug(arguments) { try { w.console.log(arguments) } catch(e) {} }28 function error(arguments) { try { w.console.error(arguments) } catch(e) {} }28 function debug(arguments) { try { w.console.log(arguments) } catch (e) {} } 29 function error(arguments) { try { w.console.error(arguments) } catch (e) {} } 29 30 30 31 var Browsing = function() { this.init.apply(this, arguments) } … … 34 35 init : function(url) { 35 36 var m = defaultTag + ' "' + document.title + '" ' 36 var m = prompt(m,'')37 m = prompt(m, '') 37 38 if (m == null) return 38 39 if (m == '') m = defaultTag … … 78 79 } 79 80 80 addEventListener('keypress', function(e) {81 var c = (e.ctrlKey)82 var s = (e.shiftKey)81 addEventListener('keypress', function(e) { 82 var c = e.ctrlKey 83 var s = e.shiftKey 83 84 var v = (e.keyCode == 13) 84 85 if (c && s && v) { 85 if (use TinyURL) {86 if (useIsgd) { 86 87 createTinyURL(document.location.href, function(url) { 87 88 new Browsing(url) … … 89 90 } 90 91 else { 91 new Browsing(document.location.href) ;92 new Browsing(document.location.href) 92 93 } 93 94 } 94 95 }, true) 95 96 96 function createTinyURL(url,callback,error) {97 GM_xmlhttpRequest({98 method : 'post',99 url : 'http://is.gd/api.php?longurl=' + encodeURIComponent(url),100 headers:{"Content-type":"application/x-www-form-urlencoded"},101 onload : function(res) {102 if (res.responseText != 'Error') callback(res.responseText)103 else if (typeof error == 'function') error(res)104 },105 onerror: error,106 })107 }97 function createTinyURL(url, callback, error) { 98 GM_xmlhttpRequest({ 99 method : 'post', 100 url : 'http://is.gd/api.php?longurl=' + encodeURIComponent(url), 101 headers: { 'Content-type': 'application/x-www-form-urlencoded' }, 102 onload : function(res) { 103 if (res.responseText != 'Error') callback(res.responseText) 104 else if (typeof error == 'function') error(res) 105 }, 106 onerror: error, 107 }) 108 } 108 109 109 110 function tinyURLError(res) { 110 if (useAlert) alert(' tinyurlfailed!')111 error(' TinyURLFailed - ' + res.status + ': ' + res.statusText)111 if (useAlert) alert('is.gd failed!') 112 error('is.gd Failed - ' + res.status + ': ' + res.statusText) 112 113 } 113 114
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)