分類
软件

Tiny Tiny RSS

Firefox 今天更新到了 68.2.0,一個比較大的改動是移除了自帶的 RSS 閱讀器。剛好前不久拿到一台免費的 Oracle Cloud,於是搭建 Tiny Tiny RSS 來做閱讀聚合。

MariaDB、php7.2、nginx 和 letsEncrypt 證書生成器的安裝網上資料很多,這裡就不貼了。

然后根据 Tiny Tiny RSS Installation Guide 一步一步来做。我是直接在nginx默認的html文件夾下 git clone 出項目,然後訪問 http://yoursite/tt-rss/install/ 來安裝,下面是遇到的問題。

未安裝 php-intl

sudo yum install php7.2-intl

文件權限不足

#首先修改文件夾權限
cd /usr/share/nginx/html/tt-rss
sudo chown -R nginx:nginx cache lock feed-icons
sudo chmod -R g+w cache lock feed-icons
#如果你的 CentOS 7 系統和我的一樣開啟了 SELinux,還需要
sudo chcon -R unconfined_u:object_r:httpd_sys_rw_content_t:s0 cache feed-icons lock

更新機制

#首先嘗試了 systemctl,沒有成功
#於是用原始的crontab
*/30 * * * * /usr/bin/php72 /usr/share/nginx/html/tt-rss/update.php --feeds --quiet

使用小撇步

  • 在偏好設定》摘要》類別里,可以新建類別。
  • 在 RSS 訂閱上右鍵,編輯摘要里可以單獨設置更新頻率。據說選項里勾上媒體快取可以緩存媒體到服務器(未驗證)。
  • 打開「全部文章」,點擊閱讀頁左上角的RSS標誌,就可以用 RSS 的方式分享自己所有的閱讀聚合。
  • 安卓版客戶端可以從 F-droid 下載,我沒有使用客戶端我使用的是 Readrops。

If it helps, please kindly consider to contribute or donate.






191218更新:Oracle Cloud 的服務器被無預警註銷,沒有通知沒有郵件什麼都沒有。但是啟動盤還在,所以可以再創建一個實例。雖然如此,仍然給人極不靠譜的感覺。新實例會產生新 IP,修改 DNS 後原來的服務就又可以用了。

藉此機會順便升級了下 Tiny Tiny RSS,由於我是通過 Git安裝的,所以需要在安裝文件夾執行下面命令就可以了。

git pull origin master
#如果你不小心改動過項目文件,可以用下面命令忽略之
git reset --hard HEAD 

更新後進入網頁可能會提示需要更新數據庫,點擊更新按鈕後就完成了升級。

本文更新於 2020/10/16。

分類
Linux 软件

Linux上的離線字典——GoldenDict

GoldenDict是一款方便的字典應用,不僅支持離線字典和屏幕取詞,也支持在線辭典服務。Fedora直接從軟件倉庫安裝 goldendict 即可sudo dnf install goldendict,默認的屏幕取詞快捷鍵是Ctrl+C+C。

分享幾個字典的下載地址:https://1drv.ms/f/s!AiSujQyFSc-uab_ItF61BBKnLUs。GoldenDict中的字典順序也是下面順序。

  1. Babylon_English_Chinese_S_.BGL
  2. Babylon_Chinese_S_English.BGL
  3. Oxford_Advanced_Learner_English-Chinese_Dictionary-4th.bgl
  4. ConciseOxfordEnglishDictionary.dsl.dz
  5. Oxford English Dictionary (2nd Edition) .bgl
  6. 现代汉英词典(金山).dsl.dz

安卓也有GoldenDict可用,我用的免費版(谷歌市場:GoldenDict Free),有最大5個字典的限制,但是也夠用了。

使用 espeak 來發音

#安裝espeak
sudo dnf install espeak
#打開GoldenDict,菜單欄依次選擇
#編輯/字典/字典來源/程式/新增
#新增內容為:
#類型:音訊
#名稱:espeak
#命令列:/usr/bin/espeak -v en -s 120 %GDWORD%
#圖示:/usr/share/doc/espeak/html/images/lips.png
#最後勾選啟用框,保存並重啟GoldenDict就可以有英文發音了

##如果要聽法語發音,
##只需要把命令列中的 en 換成 fr 即可。

更多字典可以從這些地方獲得:http://download.huzheng.org/(來自:Good offline dictionaries for GoldenDict)

使用 Speech Dispatcher 來發音

來到 2023 年,Speech Dispatcher 是新的語音生成器。這裏記錄下在 Fedora 上安裝以及命令調用的方法:

#安裝
sudo dnf install speech-dispatcher speech-dispatcher-utils
#使用
spd-say hello

本文更新於 2023/08/12。

分類
软件

youtube-dl

Edit 221015: 如果遇到一些 youtube-dl 不支持的網址,可以嘗試用 yt-dlp,來下載,比如 arte.tv 的視頻。可以用傳統的 pip 安裝:pip install yt-dlp也可以直接允許可執行文件。使用方法類似 youtube-dl。

之前用過一些在線提取和轉換YouTube視頻的服務,近來發現這些提取或轉換的鏈接要求ip一致,那就無法用洋蔥網絡下載了。好在發現youtube-dl這麼個好工具,不僅能下載單集視頻還能下載視頻列表;不僅能單獨下載字幕還能把字幕合入視頻,非常強大。目前用的這幾個參數,記錄一下。

#安裝youtube-dl
sudo dnf install youtube-dl
##單個視頻下載
#查看可下載的視頻,注意audio only的視頻,沒有伴音的哦
youtube-dl https://www.youtube.com/watch?v=qU52CFGTGu0 -F
#下載編號為22的視頻
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 -f 22
#續傳中斷的視頻
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 -f 22 --continue
#列出所有字幕
youtube-dl --proxy socks5://127.0.0.1:9150 qU52CFGTGu0 --list-subs
#只下載字幕而不下載視頻
youtube-dl --all-subs --skip-download --proxy socks5://127.0.0.1:9150 https://www.youtube.com/watch?v=qU52CFGTGu0
#使用aria2搭配proxychains實現多進程下載
sudo dnf install aria2 proxychains-ng
proxychains4 youtube-dl -f mp4 --external-downloader aria2c --external-downloader-args '-c -j4 -x 4 -s 4 -k 5M' lW0ugxbtIEE
##視頻列表下載
#將視頻列表中的視頻連接輸出到文本文件
youtube-dl -j --flat-playlist "https://www.youtube.com/playlist?list=PLATwx1z00HsdanKZcTMQEc-n_Bhu_aZ76" | jq -r '.id' | sed 's_^_https://youtu.be/_' > list.log
#從文件里讀取視頻地址並下載,下載過的會保存於done.txt不會重複下載
youtube-dl -f mp4 --external-downloader aria2c --external-downloader-args '-c -j5 -x 5 -s 5 -k 10M --max-download-limit 1024k' --batch-file list.log --download-archive done.txt

#下載分辨率是 1080 的最佳畫質音視頻
yt-dlp --format "bv*[height=1080]+ba/b" qU52CFGTGu0
#舊電視或機頂盒可能不支持 VP90 視頻編碼以及 opus 音頻編碼
#或者不識別默認的 webm 視頻文件,這時可以選擇較舊的 avc1(h264) 視頻編碼和 mp4a 音頻編碼來解決
yt-dlp qU52CFGTGu0 -F
yt-dlp qU52CFGTGu0 -f 137+140

參考:youtube-dl批量下载时,跳过之前已经下载过的文件

Using yt-dlp in command line網頁存檔

本文更新於 2024/09/20。

分類
Linux

Hourly Reminder

忙起來的時候不知不覺時間就過去了,而久坐對健康絕對不是什麼好事。那麼就產生了一個需求,提醒我時間的流逝。Android上有個不錯的開源應用Hourly Reminder,但是我是在工作的時候才需要提醒,所以最好是桌面彈窗。簡單搜索發現Fedora預裝的notify-send命令就能很好的實現toast效果,搭配crontab就能滿足需求了。

crontab -e
#單行Hourly Reminder簡潔版
0 9-18 * * 1-5 notify-send -t 6000 '整點咯' 'It is ? time.'
#Hourly Reminder python 豪華版
0 9-18 * * 1-5 /home/42/Programs/p37/bin/python /home/42/eclipse-workspace/scriptsP37/hourlyReminder.py

file:/home/42/eclipse-workspace/scriptsP37/hourlyReminder.py

#!/home/42/Programs/p37/bin/python
import time,datetime,subprocess,random

ts = int(time.time())
hour = datetime.datetime.fromtimestamp(ts).strftime('%H')
title = "現在時刻"+hour+"點整"
emojiList=['?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','☕️','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?']
content = '\r        '+random.choice(emojiList)+'\r'
subprocess.check_call(['notify-send','-t','6000',title,content])

定時任務參考自crontab guru。 Emoji複製自Get Emoji

代碼里的emoji被wordpress強制轉義,從段落里複製吧emojiList=['?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','☕️','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?','?']

本文更新於 2021/09/13。

分類
软件

Fedora使用Impactor安裝ipa

使用Impactor可以為蘋果手機安裝ipa程序,無論手機是否越獄。從Cydia Impactor下載需要的包並解壓。

./Impactor

./Impactor: error while loading shared libraries: libudev.so.0: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo ln -sf /usr/lib64/libudev.so.1 /usr/lib64/libudev.so.0

./Impactor: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo dnf install libatomic

./Impactor: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
#若出現上述錯誤則
sudo dnf install ncurses-compat-libs

啟動Impactor後,先選中手機,再在Device>Install package選擇要安裝的包,輸入蘋果賬號密碼即可。




Fedora找尋丟失庫的方法,如

./Impactor: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
sudo dnf provides libncurses.so.5
ncurses-compat-libs-6.0-8.20170212.fc26.i686 : Ncurses compatibility libraries
軟體庫    :fedora
符合之來源:
Provide    : libncurses.so.5
sudo dnf install ncurses-compat-libs
分類
說說

棄用ibus-rime

試圖在Fedora26上使用Rime輸入法,經過數小時嘗試都不能完整打出自己想要的句子,只能吐血半升後放棄。IBus Intelligent Pinyin雖然有不少缺點也傻傻的,但仍然是我目前遇到最好用的開源拼音輸入法。查看源碼發現已經智能拼音已經更新到了1.10.92,在Fedora26上嘗試編譯失敗後(一天內兩次失敗,真是受打擊?),決定升級Fedora。

迅速新裝了一個Fedora 29 Xfce,很好用,美滋滋。

分類
Linux

使用Termux搭建假wifi熱點

注:本文旨在學習研究wifi熱點相關知識,請勿用於任何違反道德之事。

需要一台Root過的Android(系統版本不低於5.0)手機,安裝好Termux和python。實現Captive Portal需要兩部分,請求重定向和授權頁面。重定向的實現有多種,這裡既然是假熱點,所以使用最簡單的iptables重定向dns。授權頁面則直接採用jczic/MicroWebSrv實現的網頁服務器。把MicroWebSrv解壓到~/scripts/MicroWeb,然後新建如下文件

#~/scripts/MicroWeb/forward.sh
remove127(){
  /system/bin/iptables -t nat -D PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.43.1:8000&&/system/bin/iptables -t nat -D PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.43.1:8000
}
add127(){
  /system/bin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.43.1:8000&&/system/bin/iptables -t nat -I PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.43.1:8000
}
if [[ $1 = "1" ]]; then
  echo "start"       
  add127
elif [[ $1 = "0" ]]; then
  echo "stop"
  remove127
fi
#~/scripts/MicroWeb/web.py
from microWebSrv import MicroWebSrv
mws = MicroWebSrv(port=8000,bindIP='0.0.0.0',webPath="/data/data/com.termux/files/home/scripts/MicroWeb/www")
mws.SetNotFoundPageUrl("http://192.168.43.1:8000/hotspot-detect.html")
mws.Start(False)
#~/scripts/MicroWeb/www/hotspot-detect.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
  
  <title>Captive Portal</title>
  <script>
  /*!
 * clipboard.js v2.0.0
 * https://zenorocha.github.io/clipboard.js
 * 
 * Licensed MIT © Zeno Rocha
 */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=3)}([function(t,e,n){var o,r,i;!function(a,c){r=[t,n(7)],o=c,void 0!==(i="function"==typeof o?o.apply(e,r):o)&&(t.exports=i)}(0,function(t,e){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(t){return t&&t.__esModule?t:{default:t}}(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),a=function(){function t(e){n(this,t),this.resolveOptions(e),this.initSelection()}return i(t,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,o.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,o.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":r(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=a})},function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return r(t,e,n);if(c.nodeList(t))return i(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function r(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function i(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return u(document.body,t,e,n)}var c=n(6),u=n(5);t.exports=o},function(t,e){function n(){}n.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){r.off(t,o),e.apply(n,arguments)}var r=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;for(o;o<r;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],r=[];if(o&&e)for(var i=0,a=o.length;i<a;i++)o[i].fn!==e&&o[i].fn._!==e&&r.push(o[i]);return r.length?n[t]=r:delete n[t],this}},t.exports=n},function(t,e,n){var o,r,i;!function(a,c){r=[t,n(0),n(2),n(1)],o=c,void 0!==(i="function"==typeof o?o.apply(e,r):o)&&(t.exports=i)}(0,function(t,e,n,o){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function u(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=r(e),s=r(n),f=r(o),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),p=function(t){function e(t,n){i(this,e);var o=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return o.resolveOptions(n),o.listenClick(t),o}return c(e,t),h(e,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===d(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,f.default)(t,"click",function(t){return e.onClick(t)})}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return u("action",t)}},{key:"defaultTarget",value:function(t){var e=u("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return u("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach(function(t){n=n&&!!document.queryCommandSupported(t)}),n}}]),e}(s.default);t.exports=p})},function(t,e){function n(t,e){for(;t&&t.nodeType!==o;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var o=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}t.exports=n},function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function r(t,e,n,r,i){return"function"==typeof t.addEventListener?o.apply(null,arguments):"function"==typeof n?o.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,function(t){return o(t,e,n,r,i)}))}function i(t,e,n,o){return function(n){n.delegateTarget=a(n.target,e),n.delegateTarget&&o.call(t,n)}}var a=n(4);t.exports=r},function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var n=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e){function n(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),r=document.createRange();r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r),e=o.toString()}return e}t.exports=n}])});
  </script>
    <style>
        .wrapper {
            text-align: center;
        }

        .button {
            position: absolute;
            top: 50%;
            margin-top:2em;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <button class="btn" id="clickButton" data-clipboard-text="just kidding :)">
            Connect to the Internet
        </button>
    </div>

    <script>
        var clipboard = new ClipboardJS('.btn');    
        clipboard.on('success', function(e) {
            console.info('Action:', e.action);
            console.info('Text:', e.text);
            console.info('Trigger:', e.trigger);

            e.clearSelection();
        });

        clipboard.on('error', function(e) {
            console.error('Action:', e.action);
            console.error('Trigger:', e.trigger);
        });  
    </script>
</body>
</html>

上面文件唯一需要修改的地方是你手機的wifi網關,可以在打開手機熱點後通過ip addr命令查看,我的是wlan0網卡,網關是192.168.43.1。

#iptable需要root權限
su
./forward.sh 1
#然后新开一个session運行web server
python web.py
#這時其他手機連上此熱點,即會彈出自定義頁面hotspot-detect.html。

本文更新於 2018/11/02。