用Ubiquity快速發佈Plurk訊息-用%l替換網址
經常在看到想要分享到Plurk的網頁時,為了複製網址和說明文字而必須操作好幾次,乾脆再修改這個Ubiquity指令,在文字裡用 %l 或 %link 替換當前網頁的網址。命令原始碼如下,訂閱方法請查看下方的相關主題。 範例:plurk shares-cn => %l (The 150 Best Online Flash Games) 。
- 原始碼:
- /*
- * Original author: http://theunfocused.net/moz/ubiquity/verbs/, Blair McBride
- * Copied from http://www.plurk.com/user/fortelin
- * sample: plurk loves Plurking test.
- * plurk loves-cn This is a link %l (Test page).
- */
- CmdUtils.CreateCommand({
- name: "plurk",
- takes: {status: noun_arb_text},
- homepage: "http://theunfocused.net/moz/ubiquity/verbs/",
- author: {name: "Blair McBride", homepage: "http://theunfocused.net/"},
- modifier: {name: "Jerry Chien"},
- license: "MPL",
- preview: function(previewBlock, statusText) {
- var previewTemplate = "將要發佈的內容如下: " +
- "${status} " +
- " 總字數為: ${chars}";
- var truncateTemplate = " 後面 ${truncate} " +
- "個字將予以刪除!";
- var previewData = {
- status: statusText.text,
- chars: statusText.text.length
- };
- var previewHTML = CmdUtils.renderTemplate(previewTemplate,
- previewData);
- if(previewData.chars > 140) {
- var truncateData = {
- truncate: previewData.chars - 140
- };
- previewHTML += CmdUtils.renderTemplate(truncateTemplate,
- truncateData);
- }
- previewBlock.innerHTML = previewHTML;
- },
- execute: function(statusText) {
- if(statusText.text.length < 1) {
- displayMessage("Plurk 內容不可空白");
- return;
- }
- var _sQualifier = "says";
- var _sLang = "tr_ch"; // 預設為繁體中文
- var _sText = statusText.text;
- var _iIndex = _sText.indexOf(" ");
- var found = false;
- if (_iIndex > 0) {
- var _aQualifiers = ["loves","likes","shares","gives","hates","wants",
- "wishes","has","will","wonders","asks","was","feels","thinks","says","is"];
- var _sVerb = _sText.substring(0, _iIndex); // 要使用的qualifier
- var _iIndex2 = _sVerb.indexOf("-"); // loves, loves-tw, loves-cn, loves-en, 減號後面加語系
- if (_iIndex2 > 0) {
- var _sVerbLang = _sVerb.substring(_iIndex2+1).toLowerCase();
- if (_sVerbLang=="tw") _sLang = "tr_ch";
- else _sLang = _sVerbLang;
- _sVerb = _sVerb.substring(0, _iIndex2); // loves-cn ==> loves
- }
- for (var ele in _aQualifiers) {
- if (_sVerb==_aQualifiers[ele]) {
- found = true;
- _sQualifier = _sVerb;
- _sText = _sText.substring(_iIndex+1);
- break;
- }
- }
- }
- // 自動替換目前頁面的網址之處理
- var _aKeywords = ["%l", "%link", "%url"]; // 可使用的3種關鍵字串
- var _sKeyword = "";
- for (var i in _aKeywords) {
- _iIndex = _sText.indexOf(_aKeywords[i]);
- if (_iIndex >= 0) {
- _sKeyword = _aKeywords[i];
- break;
- }
- }
- if (_sKeyword != "") {
- var _sURL = context.focusedWindow.location.href;
- _sText = _sText.replace(_sKeyword, _sURL); // 關鍵字串換成網址
- }
- var updateUrl = "http://www.plurk.com/TimeLine/addPlurk";
- var updateParams = {
- uid: 3170067,
- qualifier:_sQualifier,
- lang:_sLang, // en
- content: _sText
- };
- jQuery.ajax({
- type: "POST",
- url: updateUrl,
- data: updateParams,
- dataType: "json",
- error: function() {
- displayMessage("Plurk 發佈錯誤");
- },
- success: function() {
- displayMessage("Plurk 發佈成?/span>");
- }
- });
- }
- });
您可能也會有興趣的類似文章
- 用Ubiquity快速發佈 Plurk 訊息 (4則留言, 2008/09/26)
- 用Ubiquity快速發佈 Plurk 訊息-改良版 (0則留言, 2008/09/27)
- HighLight:程式碼顯示的美化工具 (0則留言, 2008/10/04)
- 新增加的FireFox Ubiquity指令:books、k+與en2zh (0則留言, 2008/10/18)
- 簡單的Mozilla Ubiquity應用:Yahoo!奇摩字典的查詢命令 (1則留言, 2008/08/30)
- 簡單的Mozilla Ubiquity應用2:將目前網頁貼上推推王的命令 (3則留言, 2008/08/31)
- 網路衝浪新幫手-無所不在的Firefox Ubiquity (10則留言, 2008/12/16)
- 幾個好用的FireFox Ubiquity命令:shorten、goto和screengrab (0則留言, 2008/10/26)
- 重置Firefox Ubiquity的設定 (0則留言, 2009/04/12)
- Ubiquity在歲末又向前邁了一小步;0.1.3釋出 (4則留言, 2008/12/31)
- 噗浪新功能:透過電子郵件/行動電話 plurk (13則留言, 2010/08/18)
- 用PlurkEasyEmoticon選取噗浪表情圖示 (7則留言, 2011/01/10)
- 指定Plurk回應串對話者的小技巧 (1則留言, 2008/09/29)
- 用AutoHotkey插入噗浪隱藏版表情符號 (8則留言, 2010/10/23)
- 幫部落格加上Plurk快速噗文按鈕[修訂] (8則留言, 2009/05/24)
Sorry, 很久沒用Google sc…