├── .gitignore ├── README.md ├── baidu_search.cplugin ├── info.lua └── main.lua ├── baidu_translate.cplugin ├── info.lua └── main.lua ├── base64.cplugin ├── base64.lua ├── info.lua └── main.lua ├── base64dec.cplugin ├── base64.lua ├── info.lua └── main.lua ├── bilibili_search.cplugin ├── info.lua └── main.lua ├── bing_search.cplugin ├── info.lua └── main.lua ├── comment.cplugin ├── info.lua └── main.lua ├── cpkgen.sh ├── cppclass.cplugin ├── README.md ├── info.lua └── main.lua ├── cppclassimp.cplugin ├── README.md ├── info.lua └── main.lua ├── douban_movie_search.cplugin ├── info.lua └── main.lua ├── ecms_tracking.cplugin ├── info.lua └── main.lua ├── getPanBaidu.cplugin ├── info.lua └── main.lua ├── get_domain.cplugin ├── info.lua └── main.lua ├── google_search.cplugin ├── info.lua └── main.lua ├── google_translate.cplugin ├── info.lua └── main.lua ├── ios_map_search.cplugin ├── info.lua └── main.lua ├── mpv_macos.cplugin ├── info.lua └── main.lua ├── objc_auto_blocks.cplugin ├── info.lua └── main.lua ├── objc_auto_new.cplugin ├── info.lua └── main.lua ├── objc_auto_property.cplugin ├── info.lua └── main.lua ├── objc_gen_property.cplugin ├── info.lua └── main.lua ├── objc_property_assign.cplugin ├── info.lua └── main.lua ├── objc_property_copy.cplugin ├── info.lua └── main.lua ├── objc_property_strong.cplugin ├── info.lua └── main.lua ├── objc_property_weak.cplugin ├── info.lua └── main.lua ├── objc_temp_singleton_header.cplugin ├── info.lua └── main.lua ├── objc_temp_singleton_imp.cplugin ├── info.lua └── main.lua ├── open_dash.cplugin ├── info.lua └── main.lua ├── openurl.cplugin ├── info.lua └── main.lua ├── remove_spaces.cplugin ├── info.lua └── main.lua ├── sfexpress.cplugin ├── info.lua └── main.lua ├── swift_singleton.cplugin ├── info.lua └── main.lua ├── urbandict.cplugin ├── info.lua └── main.lua ├── uuid.cplugin ├── info.lua ├── main.lua └── uuid.lua ├── weibo_search.cplugin ├── info.lua └── main.lua └── youdao_translate.cplugin ├── info.lua └── main.lua /.gitignore: -------------------------------------------------------------------------------- 1 | *.cpk 2 | *~ 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cpluginscript 2 | 3 | [https://clipber.com/developer/](https://clipber.com/developer/) 4 | 5 | 6 | ## 系统环境 7 | 8 | 兼容 macOS 和 Linux。 9 | Windows建议使用win10的Linux Subsystem进行开发。 10 | 11 | Linux需要安装uuidgen命令与zip命令。 12 | 13 | ## 用法: 14 | 15 | 16 | 创建插件 17 | ```` 18 | -c/--create project_name 19 | 例: ./cpkgen.sh -c myProj 20 | ```` 21 | 22 | 23 | 打包插件 24 | ```` 25 | -p/--package project_name 26 | 例: ./cpkgen.sh -p myProj.cplugin 27 | ```` 28 | -------------------------------------------------------------------------------- /baidu_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "百度搜索" 2 | plugin_bundle_id = "com.developer.A2B7154E" 3 | plugin_desc = "使用百度搜索" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /baidu_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://www.baidu.com/s?wd=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /baidu_translate.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "百度翻译" 2 | plugin_bundle_id = "com.developer.AF2C2D09" 3 | plugin_desc = "使用百度翻译当前文本" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /baidu_translate.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | local function urlencode(str) 4 | 5 | --Ensure all newlines are in CRLF form 6 | str = string.gsub (str, "\r?\n", "\r\n") 7 | 8 | --Percent-encode all non-unreserved characters 9 | --as per RFC 3986, Section 2.3 10 | --(except for space, which gets plus-encoded) 11 | str = string.gsub (str, "([^%w%-%.%_%~ ])", 12 | function (c) return string.format ("%%%02X", string.byte(c)) end) 13 | 14 | --Convert spaces to plus signs 15 | str = string.gsub (str, " ", "%%20") 16 | 17 | return str 18 | end 19 | 20 | function main(text) 21 | -- edit here 22 | local url = "http://fanyi.baidu.com/#auto/zh/" .. urlencode(text) 23 | local txt = app.openURL(url); 24 | return txt 25 | end 26 | -------------------------------------------------------------------------------- /base64.cplugin/base64.lua: -------------------------------------------------------------------------------- 1 | local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding 2 | -- encoding 3 | function enc(data) 4 | return ((data:gsub('.', function(x) 5 | local r,b='',x:byte() 6 | for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end 7 | return r; 8 | end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) 9 | if (#x < 6) then return '' end 10 | local c=0 11 | for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end 12 | return b:sub(c+1,c+1) 13 | end)..({ '', '==', '=' })[#data%3+1]) 14 | end 15 | 16 | -- decoding 17 | function dec(data) 18 | data = string.gsub(data, '[^'..b..'=]', '') 19 | return (data:gsub('.', function(x) 20 | if (x == '=') then return '' end 21 | local r,f='',(b:find(x)-1) 22 | for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end 23 | return r; 24 | end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) 25 | if (#x ~= 8) then return '' end 26 | local c=0 27 | for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end 28 | return string.char(c) 29 | end)) 30 | end 31 | -------------------------------------------------------------------------------- /base64.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "base64编码" 2 | plugin_bundle_id = "com.developer.23CCC902" 3 | plugin_desc = "base64编码" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /base64.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | require 'base64' 2 | 3 | function main(text) 4 | -- edit here 5 | local bs = enc(text) 6 | return bs 7 | end 8 | 9 | -------------------------------------------------------------------------------- /base64dec.cplugin/base64.lua: -------------------------------------------------------------------------------- 1 | local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding 2 | -- encoding 3 | function enc(data) 4 | return ((data:gsub('.', function(x) 5 | local r,b='',x:byte() 6 | for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end 7 | return r; 8 | end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) 9 | if (#x < 6) then return '' end 10 | local c=0 11 | for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end 12 | return b:sub(c+1,c+1) 13 | end)..({ '', '==', '=' })[#data%3+1]) 14 | end 15 | 16 | -- decoding 17 | function dec(data) 18 | data = string.gsub(data, '[^'..b..'=]', '') 19 | return (data:gsub('.', function(x) 20 | if (x == '=') then return '' end 21 | local r,f='',(b:find(x)-1) 22 | for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end 23 | return r; 24 | end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) 25 | if (#x ~= 8) then return '' end 26 | local c=0 27 | for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end 28 | return string.char(c) 29 | end)) 30 | end 31 | -------------------------------------------------------------------------------- /base64dec.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "base64解码" 2 | plugin_bundle_id = "com.developer.3c15c2b9fca4" 3 | plugin_desc = "base64解码" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /base64dec.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | require 'base64' 2 | 3 | function main(text) 4 | -- edit here 5 | local str = text:gsub(" ", "") 6 | str = str:gsub("\n", "") 7 | return dec(str) 8 | end 9 | 10 | -------------------------------------------------------------------------------- /bilibili_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "bilibili搜索" 2 | plugin_bundle_id = "com.developer.DD0F9D7E" 3 | plugin_desc = "在哔哩哔哩搜索" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /bilibili_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://search.bilibili.com/all?keyword=" .. urlencode(text) .. "&from_source=clipber.com" 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /bing_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "bing搜索" 2 | plugin_bundle_id = "com.developer.A45625E5" 3 | plugin_desc = "使用bing搜索" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /bing_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://www.bing.com/search?q=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /comment.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "注释(c++)" 2 | plugin_bundle_id = "com.developer.5B8FCDA7" 3 | plugin_desc = "注释当前内容" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /comment.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function main(text) 4 | -- edit here 5 | return "// " .. text 6 | end 7 | -------------------------------------------------------------------------------- /cpkgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f "$(which uuidgen)" ] 4 | then 5 | echo 'uuidgen is not installed' 6 | echo 'exp. on debian system: apt-get install uuid-runtime' 7 | echo '----------------------' 8 | exit 1 9 | fi 10 | 11 | if [ ! -f "$(which zip)" ] 12 | then 13 | echo 'zip is not installed' 14 | exit 1 15 | fi 16 | 17 | CPKGEN_VERSION="1.0" 18 | 19 | CREATE=0 20 | PACKAGE=0 21 | 22 | while [ $# -gt 0 ] 23 | do 24 | key="$1" 25 | case $key in 26 | -h|--help) 27 | echo -e "useage:\n" 28 | echo "create plugin:" 29 | echo -e "-c/--create project_name \nexp.: ./cpkgen.sh -c myProj" 30 | echo "" 31 | echo "package plugin:" 32 | echo -e "-p/--package project_name \nexp.: ./cpkgen.sh -p myProj.cplugin" 33 | exit 1 34 | ;; 35 | -c|--create) 36 | CREATE=1 37 | PROJ_NAME=$2 38 | shift 39 | ;; 40 | -p|--package) 41 | PACKAGE=1 42 | PROJ_NAME=$2 43 | shift 44 | ;; 45 | --default) 46 | DEFAULT=YES 47 | ;; 48 | *) 49 | echo "unknow arg" 50 | exit 1 51 | ;; 52 | esac 53 | shift 54 | done 55 | 56 | if [ $CREATE -eq 1 ] && [ $PACKAGE -eq 1 ] 57 | then 58 | echo "can't both create and package" 59 | exit 1 60 | fi 61 | 62 | PLUGIN_NAME="${PROJ_NAME}.cplugin" 63 | 64 | BUNDLE_ID=$(uuidgen | awk -F '-' '{print $1}') 65 | 66 | INFO_FILE="plugin_name = \"developr\"\nplugin_bundle_id = \"com.developer.${BUNDLE_ID}\"\nplugin_desc = \"信息描述\"\nplugin_version = \"1.0\"\nplugin_author = \"http://clipber.com\"\ncpkgen_version = \"${CPKGEN_VERSION}\"" 67 | 68 | MAIN_FILE="function main(text)\n\t-- edit here\n\treturn text\nend" 69 | 70 | if [ $CREATE -eq 1 ] 71 | then 72 | echo "create plugin $PROJ_NAME in current dir" 73 | mkdir -p "$PLUGIN_NAME" 74 | echo -e $INFO_FILE > ${PLUGIN_NAME}/info.lua 75 | echo -e $MAIN_FILE > ${PLUGIN_NAME}/main.lua 76 | fi 77 | 78 | 79 | if [ $PACKAGE -eq 1 ] 80 | then 81 | PLUGIN_NAME=$(basename -s .cplugin $PROJ_NAME) 82 | PLUGIN_DIR="${PLUGIN_NAME}.cplugin" 83 | rm -rf Payload "${PLUGIN_NAME}.cpk" 84 | mkdir -p Payload 85 | cp -a $PLUGIN_DIR Payload/ 86 | zip -r -1 "${PLUGIN_NAME}.cpk" Payload 87 | rm -rf Payload 88 | fi 89 | 90 | -------------------------------------------------------------------------------- /cppclass.cplugin/README.md: -------------------------------------------------------------------------------- 1 | ## 插件功能 2 | 生成C++ class模版 3 | 4 | ## 使用方法 5 | 6 | 输入: 7 | 8 | ``` 9 | a::b::c 10 | ``` 11 | 12 | 自动生成: 13 | 14 | ``` 15 | namespace a { 16 | namespace b { 17 | 18 | 19 | class c { 20 | 21 | private: 22 | 23 | public: 24 | 25 | c(); 26 | ~c(); 27 | 28 | }; 29 | 30 | 31 | }///b 32 | }///a 33 | 34 | ``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /cppclass.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "生成c++类" 2 | plugin_bundle_id = "com.developer.FFCFB3E6" 3 | plugin_desc = "生成c++类" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /cppclass.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | 2 | function main(text) 3 | -- edit here 4 | t = {} 5 | local pattern = string.format("([^%s]+)", "::") 6 | text:gsub(pattern, function(c) t[#t+1] = c end) 7 | 8 | local class = t[#t] 9 | table.remove(t, #t) 10 | local head = "" 11 | local body = [[ 12 | 13 | 14 | class <##> { 15 | 16 | private: 17 | 18 | public: 19 | 20 | <##>(); 21 | ~<##>(); 22 | 23 | }; 24 | 25 | 26 | ]] 27 | local tail = "" 28 | if t[1] then 29 | for i,v in ipairs(t) do 30 | head = head .. "namespace " .. v .. " {\n" 31 | tail = "}///" .. v .. "\n" .. tail 32 | end 33 | end 34 | 35 | local sign = "\n///This Class was generated by clipber.com\n" 36 | local imp = head .. body .. tail .. sign 37 | 38 | return imp:gsub("<##>", class) 39 | end 40 | 41 | -------------------------------------------------------------------------------- /cppclassimp.cplugin/README.md: -------------------------------------------------------------------------------- 1 | ## 插件功能 2 | 生成C++ class实现 3 | 4 | ## 使用方法 5 | 6 | 输入: 7 | 8 | ``` 9 | a::b::c 10 | ``` 11 | 12 | 自动生成: 13 | 14 | ``` 15 | namespace a { 16 | namespace b { 17 | 18 | c::c() { 19 | 20 | } 21 | 22 | c::~c() { 23 | 24 | } 25 | 26 | 27 | 28 | }///b 29 | }///a 30 | 31 | ``` 32 | 33 | 34 | -------------------------------------------------------------------------------- /cppclassimp.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "生成c++类实现" 2 | plugin_bundle_id = "com.developer.6A92F089" 3 | plugin_desc = "生成c++类实现" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /cppclassimp.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | 2 | function main(text) 3 | -- edit here 4 | t = {} 5 | local pattern = string.format("([^%s]+)", "::") 6 | text:gsub(pattern, function(c) t[#t+1] = c end) 7 | 8 | local class = t[#t] 9 | table.remove(t, #t) 10 | local head = "" 11 | local body = [[ 12 | 13 | <##>::<##>() { 14 | 15 | } 16 | 17 | <##>::~<##>() { 18 | 19 | } 20 | 21 | 22 | 23 | ]] 24 | local tail = "" 25 | if t[1] then 26 | for i,v in ipairs(t) do 27 | head = head .. "namespace " .. v .. " {\n" 28 | tail = "}///" .. v .. "\n" .. tail 29 | end 30 | end 31 | 32 | local sign = "\n///This Class was generated by clipber.com\n" 33 | local imp = head .. body .. tail .. sign 34 | 35 | return imp:gsub("<##>", class) 36 | end 37 | 38 | -------------------------------------------------------------------------------- /douban_movie_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "豆瓣电影搜索" 2 | plugin_bundle_id = "com.developer.14292CFE" 3 | plugin_desc = "搜索豆瓣电影" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /douban_movie_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://movie.douban.com/subject_search?cat=1002&search_text=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /ecms_tracking.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "易客满查询" 2 | plugin_bundle_id = "com.developer.28167D82" 3 | plugin_desc = "查询易客满物流单号" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /ecms_tracking.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://consignee.ecmsglobal.com/brige/showtracking?lang=zh&trackingno=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /getPanBaidu.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "获取百度网盘提取码" 2 | plugin_bundle_id = "com.clipber.844CD25E" 3 | plugin_desc = "获取百度网盘提取码" 4 | plugin_version = "1.0" 5 | plugin_author = "https://github.com/kakasearch" 6 | -------------------------------------------------------------------------------- /getPanBaidu.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | i = string.find(text, "pan.baidu.com") 3 | if i == nil then return "" end 4 | _,_,str=string.find(text,"提取码.-(%w%w%w%w)"); 5 | return str 6 | end 7 | -------------------------------------------------------------------------------- /get_domain.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "获取域名" 2 | plugin_bundle_id = "com.developer.3815FC19" 3 | plugin_desc = "从URL中获取域名" 4 | plugin_version = "1.0" 5 | plugin_author = "https://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /get_domain.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | local domain = text:match('^%w+://([^/]+)') 4 | if domain == nil then return "" end 5 | return domain 6 | end 7 | -------------------------------------------------------------------------------- /google_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "Google搜索" 2 | plugin_bundle_id = "com.developer.4989A89A" 3 | plugin_desc = "使用Google搜索" 4 | plugin_version = "1.1" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /google_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://www.google.com.hk/search?q=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /google_translate.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "Google翻译" 2 | plugin_bundle_id = "com.developer.0E4343A4" 3 | plugin_desc = "使用Google翻译字符串" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /google_translate.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://translate.google.com/#auto/zh-CN/" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /ios_map_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "iOS地图搜索" 2 | plugin_bundle_id = "com.developer.03CDD665" 3 | plugin_desc = "在地图中搜索" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /ios_map_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | local function urlencode(str) 4 | 5 | --Ensure all newlines are in CRLF form 6 | str = string.gsub (str, "\r?\n", "\r\n") 7 | 8 | --Percent-encode all non-unreserved characters 9 | --as per RFC 3986, Section 2.3 10 | --(except for space, which gets plus-encoded) 11 | str = string.gsub (str, "([^%w%-%.%_%~ ])", 12 | function (c) return string.format ("%%%02X", string.byte(c)) end) 13 | 14 | --Convert spaces to plus signs 15 | str = string.gsub (str, " ", "+") 16 | 17 | return str 18 | end 19 | 20 | function main(text) 21 | -- edit here 22 | local url = "http://maps.apple.com/?q=" .. urlencode(text) 23 | local txt = app.openURL(url); 24 | return txt 25 | end 26 | -------------------------------------------------------------------------------- /mpv_macos.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "mpv打开URL" 2 | plugin_bundle_id = "com.developer.793D81C4" 3 | plugin_desc = "使用mpv打开URL" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /mpv_macos.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "mpv://" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /objc_auto_blocks.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc自动block" 2 | plugin_bundle_id = "com.developer.5514217F" 3 | plugin_desc = "检索名称自动生成block语法" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_auto_blocks.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function magiclines(s) 2 | if s:sub(-1)~="\n" then s=s.."\n" end 3 | return s:gmatch("(.-)\n") 4 | end 5 | 6 | function checkStynax(s) 7 | len = string.len(s) 8 | lastchar = string.sub(s, len, len) 9 | print(lastchar) 10 | if lastchar == ";" then 11 | return s; 12 | else 13 | return s .. ";" 14 | end 15 | end 16 | 17 | function main(text) 18 | -- edit here 19 | r = "" 20 | pt = string.lower(string.gsub(text,"%s+", "")) 21 | if string.find(pt, ".*var.*") then 22 | r = "<#returnType#> (^<#blockName#>)(<#parameterTypes#>) = ^<#returnType#>(<#parameters#>) {<#...#>};" 23 | elseif string.find(pt, ".*prop.*") then 24 | r = "@property (nonatomic, copy, nullable) " .. "<#returnType#> (^" .. text .. ")(<#parameterTypes#>);" 25 | elseif string.find(pt, ".*func.*") then 26 | r = "- (void)<#someMethodThatTakesABlock#>:(<#returnType#> (^)(<#parameterTypes#>))<#blockName#>;" 27 | elseif string.find(pt, ".*typedef.*") then 28 | r = "typedef <#returnType#> (^<#TypeName#>)(<#parameterTypes#>);" 29 | else 30 | r = "@property (nonatomic, copy, nullable) " .. "<#returnType#> (^" .. text .. ")(<#parameterTypes#>);" 31 | end 32 | return r 33 | end 34 | 35 | -------------------------------------------------------------------------------- /objc_auto_new.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc自动new" 2 | plugin_bundle_id = "com.clipber.08EABDF2" 3 | plugin_desc = "自动生成new语法" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_auto_new.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function magiclines(s) 2 | if s:sub(-1)~="\n" then s=s.."\n" end 3 | return s:gmatch("(.-)\n") 4 | end 5 | 6 | function main(text) 7 | -- edit here 8 | r = "" 9 | for line in magiclines(text) do 10 | pt = string.gsub(line,"%s+", "") 11 | if string.find(pt, "^label") then 12 | r = r .. "\nUILabel * " .. pt .. " = [UILabel new];" 13 | end 14 | if string.find(pt, "^_label") then 15 | r = r .. "\n" .. pt .. " = [UILabel new];" 16 | end 17 | if string.find(pt, "^button") then 18 | r = r .. "\nUIButton * " .. pt .. " = [UIButton new];" 19 | end 20 | if string.find(pt, "^_button") then 21 | r = r .. "\n" .. pt .. " = [UIButton new];" 22 | end 23 | if string.find(pt, "^tableView") then 24 | r = r .. "\nUITableView * " .. pt .. " = [UITableView new];" 25 | end 26 | if string.find(pt, "^_tableView") then 27 | r = r .. "\n" .. pt .. " = [UITableView new];" 28 | end 29 | if string.find(pt, "^imageView") then 30 | r = r .. "\nUIImageView * " .. pt .. " = [UIImageView new];" 31 | end 32 | if string.find(pt, "^_imageView") then 33 | r = r .. "\n" .. pt .. " = [UIImageView new];" 34 | end 35 | end 36 | return r 37 | end 38 | 39 | -------------------------------------------------------------------------------- /objc_auto_property.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc自动property" 2 | plugin_bundle_id = "com.developer.68044E6D" 3 | plugin_desc = "根据类型自动生成property语法" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_auto_property.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function magiclines(s) 2 | if s:sub(-1)~="\n" then s=s.."\n" end 3 | return s:gmatch("(.-)\n") 4 | end 5 | 6 | function checkStynax(s) 7 | len = string.len(s) 8 | lastchar = string.sub(s, len, len) 9 | print(lastchar) 10 | if lastchar == ";" then 11 | return s; 12 | else 13 | return s .. ";" 14 | end 15 | end 16 | 17 | function main(text) 18 | -- edit here 19 | r = "" 20 | pt = string.lower(string.gsub(text,"%s+", "")) 21 | if string.find(pt, ".*delegate.*") then 22 | r = "@property (nonatomic, weak) " .. text 23 | elseif string.find(pt, ".*view.*") then 24 | r = "@property (nonatomic, strong) " .. text 25 | elseif string.find(pt, ".*block.*") then 26 | r = "@property (nonatomic, copy, nullable) " .. "<#returnType#> (^" .. text .. ")(<#parameterTypes#>)" 27 | elseif string.find(pt, "^cg.*") then 28 | r = "@property (nonatomic, assign) " .. text 29 | elseif string.find(pt, "^bool.*") then 30 | r = "@property (nonatomic, assign) " .. text 31 | elseif string.find(pt, ".*float.*") then 32 | r = "@property (nonatomic, assign) " .. text 33 | elseif string.find(pt, ".*double.*") then 34 | r = "@property (nonatomic, assign) " .. text 35 | elseif string.find(pt, ".*long.*") then 36 | r = "@property (nonatomic, assign) " .. text 37 | elseif string.find(pt, ".*unsigned.*") then 38 | r = "@property (nonatomic, assign) " .. text 39 | elseif string.find(pt, ".*int.*") then 40 | r = "@property (nonatomic, assign) " .. text 41 | elseif string.find(pt, ".*nsstring.*") then 42 | r = "@property (nonatomic, copy) " .. text 43 | else 44 | r = "@property (nonatomic, strong) " .. text 45 | end 46 | return checkStynax(r) 47 | end 48 | 49 | -------------------------------------------------------------------------------- /objc_gen_property.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc生成属性" 2 | plugin_bundle_id = "com.clipber.F1BC52DA" 3 | plugin_desc = "根据变量前缀生成objc属性" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_gen_property.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function magiclines(s) 2 | if s:sub(-1)~="\n" then s=s.."\n" end 3 | return s:gmatch("(.-)\n") 4 | end 5 | 6 | function main(text) 7 | -- edit here 8 | r = "" 9 | for line in magiclines(text) do 10 | pt = string.gsub(line,"%s+", "") 11 | if string.find(pt, "^label") then 12 | r = r .. "\n@property (nonatomic, strong) UILabel * " .. pt .. ";" 13 | end 14 | if string.find(pt, "^button") then 15 | r = r .. "\n@property (nonatomic, strong) UIButton * " .. pt .. ";" 16 | end 17 | if string.find(pt, "^tableView") then 18 | r = r .. "\n@property (nonatomic, strong) UITableView * " .. pt .. ";" 19 | end 20 | if string.find(pt, "^imageView") then 21 | r = r .. "\n@property (nonatomic, strong) UIImageView * " .. pt .. ";" 22 | end 23 | end 24 | return r 25 | end 26 | 27 | -------------------------------------------------------------------------------- /objc_property_assign.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc property assign" 2 | plugin_bundle_id = "com.developer.197830FE" 3 | plugin_desc = "信息描述" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_property_assign.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | if text then 4 | return "@property (nonatomic, assign) " .. text 5 | else 6 | return "@property (nonatomic, assign) " 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /objc_property_copy.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc property copy" 2 | plugin_bundle_id = "com.developer.0E825DEB" 3 | plugin_desc = "信息描述" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_property_copy.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | if text then 4 | return "@property (nonatomic, copy) " .. text 5 | else 6 | return "@property (nonatomic, copy) " 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /objc_property_strong.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc property strong" 2 | plugin_bundle_id = "com.developer.E598A47C" 3 | plugin_desc = "信息描述" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_property_strong.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | if text then 4 | return "@property (nonatomic, strong) " .. text 5 | else 6 | return "@property (nonatomic, strong) " 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /objc_property_weak.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc property weak" 2 | plugin_bundle_id = "com.developer.88021278" 3 | plugin_desc = "信息描述" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_property_weak.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | if text then 4 | return "@property (nonatomic, weak) " .. text 5 | else 6 | return "@property (nonatomic, weak) " 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /objc_temp_singleton_header.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc单例header" 2 | plugin_bundle_id = "com.clipber.singleton" 3 | plugin_desc = "objc单例的模版" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_temp_singleton_header.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | header = [[ 4 | @interface <##>(Singleton) 5 | 6 | + (<##>*)sharedInstance; 7 | 8 | @end 9 | ]] 10 | return header:gsub("<##>", text) 11 | end 12 | -------------------------------------------------------------------------------- /objc_temp_singleton_imp.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "objc单例实现" 2 | plugin_bundle_id = "com.clipber.singletonimp" 3 | plugin_desc = "objc单例的实现" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /objc_temp_singleton_imp.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | imp = [[ 3 | @implementation <##> (Singleton) 4 | 5 | __strong static <##> * sharedSingleton_ = nil; 6 | 7 | - (void) operation 8 | { 9 | // DBFetcher 10 | NSLog(@"Singleton"); 11 | } 12 | 13 | + (<##> *)sharedInstance 14 | { 15 | static dispatch_once_t pred = 0; 16 | dispatch_once(&pred, ^{ 17 | sharedSingleton_ = [[self alloc] init]; 18 | }); 19 | return sharedSingleton_; 20 | } 21 | 22 | @end]] 23 | return imp:gsub("<##>", text) 24 | end 25 | -------------------------------------------------------------------------------- /open_dash.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "Dash搜索" 2 | plugin_bundle_id = "com.developer.97B954FA" 3 | plugin_desc = "搜索Dash文档" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /open_dash.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | local function urlencode(str) 4 | 5 | --Ensure all newlines are in CRLF form 6 | str = string.gsub (str, "\r?\n", "%%0A") 7 | --Convert spaces to plus signs 8 | str = string.gsub (str, " ", "%%20") 9 | 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local txt = app.openURL("dash://" .. urlencode(text)); 16 | return txt 17 | end 18 | -------------------------------------------------------------------------------- /openurl.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "打开URL" 2 | plugin_bundle_id = "com.developer.EE4681C4" 3 | plugin_desc = "[URL]schema" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /openurl.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | --local app = require("app") 2 | 3 | -- 判断是否是合法域名(必须包含至少一个点) 4 | function is_domain(s) 5 | return s:match("^%w[%w%-]*%.%w[%w%-%.]*%w$") ~= nil 6 | end 7 | 8 | -- 判断是否是 URL(任意 scheme://host...) 9 | function is_url(s) 10 | return s:match("^[%a][%w+%-%.]*://") ~= nil 11 | end 12 | 13 | -- 提取文本中所有域名和 URL,结果去重 14 | function extract_domains_and_urls(text) 15 | local results = {} 16 | local seen = {} 17 | for word in text:gmatch("[^%s%p]+[%w%-%.:/%?&=]*") do 18 | if not seen[word] then 19 | if is_domain(word) then 20 | local tmp_url = "https://" .. word 21 | table.insert(results, tmp_url) 22 | end 23 | if is_url(word) then 24 | table.insert(results, word) 25 | end 26 | seen[word] = true 27 | end 28 | end 29 | return results 30 | end 31 | 32 | 33 | local function urlencode(str) 34 | --Ensure all newlines are in CRLF form 35 | str = string.gsub (str, "\r?\n", "%%0A") 36 | --Convert spaces to plus signs 37 | str = string.gsub (str, " ", "%%20") 38 | return str 39 | end 40 | 41 | function main(text) 42 | local found = extract_domains_and_urls(text) 43 | for _, item in ipairs(found) do 44 | app.openURL(urlencode(item)) 45 | end 46 | return "" 47 | end 48 | 49 | -------------------------------------------------------------------------------- /remove_spaces.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "删除空格" 2 | plugin_bundle_id = "com.developer.96E36F0C" 3 | plugin_desc = "删除空格" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /remove_spaces.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | if text == nil then 4 | return "" 5 | end 6 | return text:gsub(" ", "") 7 | end 8 | 9 | -------------------------------------------------------------------------------- /sfexpress.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "顺丰快递" 2 | plugin_bundle_id = "com.developer.152D7A16" 3 | plugin_desc = "顺丰快递单号跟踪" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /sfexpress.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | local function urlencode(str) 4 | 5 | --Ensure all newlines are in CRLF form 6 | str = string.gsub (str, "\r?\n", "\r\n") 7 | 8 | --Percent-encode all non-unreserved characters 9 | --as per RFC 3986, Section 2.3 10 | --(except for space, which gets plus-encoded) 11 | str = string.gsub (str, "([^%w%-%.%_%~ ])", 12 | function (c) return string.format ("%%%02X", string.byte(c)) end) 13 | 14 | --Convert spaces to plus signs 15 | str = string.gsub (str, " ", "%%20") 16 | 17 | return str 18 | end 19 | 20 | function main(text) 21 | -- edit here 22 | local url = "http://www.sf-express.com/CN/sc/dynamic_function/waybill/#search/bill-number/" .. urlencode(text) 23 | local txt = app.openURL(url); 24 | return txt 25 | end 26 | -------------------------------------------------------------------------------- /swift_singleton.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "swift单例" 2 | plugin_bundle_id = "com.clipber.9A167315" 3 | plugin_desc = "生成swift单例" 4 | plugin_version = "1.0" 5 | plugin_author = "https://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /swift_singleton.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | function main(text) 2 | -- edit here 3 | imp = [[ 4 | extension <##> { 5 | static let shared :<##> = <##>() 6 | 7 | @objc class func sharedInstance() -> <##> { 8 | return shared 9 | } 10 | } 11 | ]] 12 | return imp:gsub("<##>", text) 13 | end 14 | -------------------------------------------------------------------------------- /urbandict.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "urbandictionary" 2 | plugin_bundle_id = "com.developer.E5C1C880" 3 | plugin_desc = "使用urban字典查询" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /urbandict.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://www.urbandictionary.com/define.php?term=" .. urlencode(text) 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /uuid.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "uuid" 2 | plugin_bundle_id = "com.developer.0498C75E" 3 | plugin_desc = "生成uuid" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /uuid.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local uuid = require("uuid") 2 | function main(text) 3 | -- edit here 4 | return uuid() 5 | end 6 | -------------------------------------------------------------------------------- /uuid.cplugin/uuid.lua: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------------- 2 | -- Copyright 2012 Rackspace (original), 2013 Thijs Schreijer (modifications) 3 | -- 4 | -- Licensed under the Apache License, Version 2.0 (the "License"); 5 | -- you may not use this file except in compliance with the License. 6 | -- You may obtain a copy of the License at 7 | -- 8 | -- http://www.apache.org/licenses/LICENSE-2.0 9 | -- 10 | -- Unless required by applicable law or agreed to in writing, software 11 | -- distributed under the License is distributed on an "AS-IS" BASIS, 12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | -- See the License for the specific language governing permissions and 14 | -- limitations under the License. 15 | -- 16 | -- see http://www.ietf.org/rfc/rfc4122.txt 17 | -- 18 | -- Note that this is not a true version 4 (random) UUID. Since `os.time()` precision is only 1 second, it would be hard 19 | -- to guarantee spacial uniqueness when two hosts generate a uuid after being seeded during the same second. This 20 | -- is solved by using the node field from a version 1 UUID. It represents the mac address. 21 | -- 22 | -- 28-apr-2013 modified by Thijs Schreijer from the original [Rackspace code](https://github.com/kans/zirgo/blob/807250b1af6725bad4776c931c89a784c1e34db2/util/uuid.lua) as a generic Lua module. 23 | -- Regarding the above mention on `os.time()`; the modifications use the `socket.gettime()` function from LuaSocket 24 | -- if available and hence reduce that problem (provided LuaSocket has been loaded before uuid). 25 | -- 26 | -- **6-nov-2015 Please take note of this issue**; [https://github.com/Mashape/kong/issues/478](https://github.com/Mashape/kong/issues/478) 27 | -- It demonstrates the problem of using time as a random seed. Specifically when used from multiple processes. 28 | -- So make sure to seed only once, application wide. And to not have multiple processes do that 29 | -- simultaneously (like nginx does for example). 30 | 31 | local M = {} 32 | local math = require('math') 33 | local os = require('os') 34 | local string = require('string') 35 | 36 | local bitsize = 32 -- bitsize assumed for Lua VM. See randomseed function below. 37 | local lua_version = tonumber(_VERSION:match("%d%.*%d*")) -- grab Lua version used 38 | 39 | local MATRIX_AND = {{0,0},{0,1} } 40 | local MATRIX_OR = {{0,1},{1,1}} 41 | local HEXES = '0123456789abcdef' 42 | 43 | local math_floor = math.floor 44 | local math_random = math.random 45 | local math_abs = math.abs 46 | local string_sub = string.sub 47 | local to_number = tonumber 48 | local assert = assert 49 | local type = type 50 | 51 | -- performs the bitwise operation specified by truth matrix on two numbers. 52 | local function BITWISE(x, y, matrix) 53 | local z = 0 54 | local pow = 1 55 | while x > 0 or y > 0 do 56 | z = z + (matrix[x%2+1][y%2+1] * pow) 57 | pow = pow * 2 58 | x = math_floor(x/2) 59 | y = math_floor(y/2) 60 | end 61 | return z 62 | end 63 | 64 | local function INT2HEX(x) 65 | local s,base = '',16 66 | local d 67 | while x > 0 do 68 | d = x % base + 1 69 | x = math_floor(x/base) 70 | s = string_sub(HEXES, d, d)..s 71 | end 72 | while #s < 2 do s = "0" .. s end 73 | return s 74 | end 75 | 76 | ---------------------------------------------------------------------------- 77 | -- Creates a new uuid. Either provide a unique hex string, or make sure the 78 | -- random seed is properly set. The module table itself is a shortcut to this 79 | -- function, so `my_uuid = uuid.new()` equals `my_uuid = uuid()`. 80 | -- 81 | -- For proper use there are 3 options; 82 | -- 83 | -- 1. first require `luasocket`, then call `uuid.seed()`, and request a uuid using no 84 | -- parameter, eg. `my_uuid = uuid()` 85 | -- 2. use `uuid` without `luasocket`, set a random seed using `uuid.randomseed(some_good_seed)`, 86 | -- and request a uuid using no parameter, eg. `my_uuid = uuid()` 87 | -- 3. use `uuid` without `luasocket`, and request a uuid using an unique hex string, 88 | -- eg. `my_uuid = uuid(my_networkcard_macaddress)` 89 | -- 90 | -- @return a properly formatted uuid string 91 | -- @param hwaddr (optional) string containing a unique hex value (e.g.: `00:0c:29:69:41:c6`), to be used to compensate for the lesser `math_random()` function. Use a mac address for solid results. If omitted, a fully randomized uuid will be generated, but then you must ensure that the random seed is set properly! 92 | -- @usage 93 | -- local uuid = require("uuid") 94 | -- print("here's a new uuid: ",uuid()) 95 | function M.new(hwaddr) 96 | -- bytes are treated as 8bit unsigned bytes. 97 | local bytes = { 98 | math_random(0, 255), 99 | math_random(0, 255), 100 | math_random(0, 255), 101 | math_random(0, 255), 102 | math_random(0, 255), 103 | math_random(0, 255), 104 | math_random(0, 255), 105 | math_random(0, 255), 106 | math_random(0, 255), 107 | math_random(0, 255), 108 | math_random(0, 255), 109 | math_random(0, 255), 110 | math_random(0, 255), 111 | math_random(0, 255), 112 | math_random(0, 255), 113 | math_random(0, 255) 114 | } 115 | 116 | if hwaddr then 117 | assert(type(hwaddr)=="string", "Expected hex string, got "..type(hwaddr)) 118 | -- Cleanup provided string, assume mac address, so start from back and cleanup until we've got 12 characters 119 | local i,str = #hwaddr, hwaddr 120 | hwaddr = "" 121 | while i>0 and #hwaddr<12 do 122 | local c = str:sub(i,i):lower() 123 | if HEXES:find(c, 1, true) then 124 | -- valid HEX character, so append it 125 | hwaddr = c..hwaddr 126 | end 127 | i = i - 1 128 | end 129 | assert(#hwaddr == 12, "Provided string did not contain at least 12 hex characters, retrieved '"..hwaddr.."' from '"..str.."'") 130 | 131 | -- no split() in lua. :( 132 | bytes[11] = to_number(hwaddr:sub(1, 2), 16) 133 | bytes[12] = to_number(hwaddr:sub(3, 4), 16) 134 | bytes[13] = to_number(hwaddr:sub(5, 6), 16) 135 | bytes[14] = to_number(hwaddr:sub(7, 8), 16) 136 | bytes[15] = to_number(hwaddr:sub(9, 10), 16) 137 | bytes[16] = to_number(hwaddr:sub(11, 12), 16) 138 | end 139 | 140 | -- set the version 141 | bytes[7] = BITWISE(bytes[7], 0x0f, MATRIX_AND) 142 | bytes[7] = BITWISE(bytes[7], 0x40, MATRIX_OR) 143 | -- set the variant 144 | bytes[9] = BITWISE(bytes[7], 0x3f, MATRIX_AND) 145 | bytes[9] = BITWISE(bytes[7], 0x80, MATRIX_OR) 146 | return INT2HEX(bytes[1])..INT2HEX(bytes[2])..INT2HEX(bytes[3])..INT2HEX(bytes[4]).."-".. 147 | INT2HEX(bytes[5])..INT2HEX(bytes[6]).."-".. 148 | INT2HEX(bytes[7])..INT2HEX(bytes[8]).."-".. 149 | INT2HEX(bytes[9])..INT2HEX(bytes[10]).."-".. 150 | INT2HEX(bytes[11])..INT2HEX(bytes[12])..INT2HEX(bytes[13])..INT2HEX(bytes[14])..INT2HEX(bytes[15])..INT2HEX(bytes[16]) 151 | end 152 | 153 | ---------------------------------------------------------------------------- 154 | -- Improved randomseed function. 155 | -- Lua 5.1 and 5.2 both truncate the seed given if it exceeds the integer 156 | -- range. If this happens, the seed will be 0 or 1 and all randomness will 157 | -- be gone (each application run will generate the same sequence of random 158 | -- numbers in that case). This improved version drops the most significant 159 | -- bits in those cases to get the seed within the proper range again. 160 | -- @param seed the random seed to set (integer from 0 - 2^32, negative values will be made positive) 161 | -- @return the (potentially modified) seed used 162 | -- @usage 163 | -- local socket = require("socket") -- gettime() has higher precision than os.time() 164 | -- local uuid = require("uuid") 165 | -- -- see also example at uuid.seed() 166 | -- uuid.randomseed(socket.gettime()*10000) 167 | -- print("here's a new uuid: ",uuid()) 168 | function M.randomseed(seed) 169 | seed = math_floor(math_abs(seed)) 170 | if seed >= (2^bitsize) then 171 | -- integer overflow, so reduce to prevent a bad seed 172 | seed = seed - math_floor(seed / 2^bitsize) * (2^bitsize) 173 | end 174 | if lua_version < 5.2 then 175 | -- 5.1 uses (incorrect) signed int 176 | math.randomseed(seed - 2^(bitsize-1)) 177 | else 178 | -- 5.2 uses (correct) unsigned int 179 | math.randomseed(seed) 180 | end 181 | return seed 182 | end 183 | 184 | ---------------------------------------------------------------------------- 185 | -- Seeds the random generator. 186 | -- It does so in 2 possible ways; 187 | -- 188 | -- 1. use `os.time()`: this only offers resolution to one second (used when 189 | -- LuaSocket hasn't been loaded yet 190 | -- 2. use luasocket `gettime()` function, but it only does so when LuaSocket 191 | -- has been required already. 192 | -- @usage 193 | -- local socket = require("socket") -- gettime() has higher precision than os.time() 194 | -- -- LuaSocket loaded, so below line does the same as the example from randomseed() 195 | -- uuid.seed() 196 | -- print("here's a new uuid: ",uuid()) 197 | function M.seed() 198 | if package.loaded["socket"] and package.loaded["socket"].gettime then 199 | return M.randomseed(package.loaded["socket"].gettime()*10000) 200 | else 201 | return M.randomseed(os.time()) 202 | end 203 | end 204 | 205 | return setmetatable( M, { __call = function(self, hwaddr) return self.new(hwaddr) end} ) 206 | -------------------------------------------------------------------------------- /weibo_search.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "微博搜索" 2 | plugin_bundle_id = "com.developer.61DCB415" 3 | plugin_desc = "在微博搜索关键字" 4 | plugin_version = "1.0" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /weibo_search.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | function urlencode(str) 4 | if (str) then 5 | str = string.gsub (str, "\n", "\r\n") 6 | str = string.gsub (str, "([^%w ])", 7 | function (c) return string.format ("%%%02X", string.byte(c)) end) 8 | str = string.gsub (str, " ", "+") 9 | end 10 | return str 11 | end 12 | 13 | function main(text) 14 | -- edit here 15 | local url = "https://s.weibo.com/weibo/" .. urlencode(text) .. "?topnav=1&wvr=6&b=1" .. "&from_source=clipber.com" 16 | local txt = app.openURL(url); 17 | return txt 18 | end 19 | -------------------------------------------------------------------------------- /youdao_translate.cplugin/info.lua: -------------------------------------------------------------------------------- 1 | plugin_name = "有道翻译" 2 | plugin_bundle_id = "com.developer.E5D10E44" 3 | plugin_desc = "使用有道翻译" 4 | plugin_version = "1.1" 5 | plugin_author = "http://clipber.com" 6 | cpkgen_version = "1.0" 7 | -------------------------------------------------------------------------------- /youdao_translate.cplugin/main.lua: -------------------------------------------------------------------------------- 1 | local app = require("app") 2 | 3 | local function urlencode(str) 4 | 5 | --Ensure all newlines are in CRLF form 6 | str = string.gsub (str, "\r?\n", "\r\n") 7 | 8 | --Percent-encode all non-unreserved characters 9 | --as per RFC 3986, Section 2.3 10 | --(except for space, which gets plus-encoded) 11 | str = string.gsub (str, "([^%w%-%.%_%~ ])", 12 | function (c) return string.format ("%%%02X", string.byte(c)) end) 13 | 14 | --Convert spaces to plus signs 15 | str = string.gsub (str, " ", "%%20") 16 | 17 | return str 18 | end 19 | 20 | function main(text) 21 | -- edit here 22 | local url = "https://www.youdao.com/w/eng/" .. urlencode(text) 23 | local txt = app.openURL(url); 24 | return txt 25 | end 26 | --------------------------------------------------------------------------------