在台灣受限於要保護青少年的法令,所以上 ptt 很麻煩會彈出確認網頁:
您即將進入之看板內容需滿十八歲方可瀏覽
需要多點一個確定,要如何省下點確定的時間?
請在瀏覽器裡安裝 Redirector 的擴充元件:
https://chrome.google.com/webstore/detail/redirector/ocgpenflpmgnfapjedencafcfakcekcd
使用方法:
在 chrome 瀏覽器點 Redirector extension 的 Options 進行設定, 彈出畫面後, 按 “Create new redirect”(建立新的重導)
輸入我幫你準備好的規則後, 按 “Save”(存檔) 就結束了, 以後不用在 ptt 上按確定:
- Example URL: https://www.ptt.cc/ask/over18?from=%2Fbbs%2FGossiping%2FM.1691597576.A.775.html
- Include pattern: https://www.ptt.cc/ask/over18\?from=\%2F([a-zA-Z0-9_-]+)\%2F([a-zA-Z0-9_-]+)\%2F([a-zA-Z0-9]+.*)
- Redirect to: https://www.ptt.cc/$1/$2/$3
- Example result: https://www.ptt.cc/bbs/Gossiping/M.1691597576.A.775.html
Redirector 官方的教學網頁
Web browser extension (Firefox, Vivaldi, Chrome, Opera, Edge) to redirect URLs based on regex or wildcard patterns.
https://github.com/einaregilsson/Redirector
使用範例:
De-mobilizer
- Example URL:
https://en.m.wikipedia.org/
- Include pattern:
^(https?://)([a-z0-9-]*\.)m(?:obile)?\.(.*)
- Redirect to:
$1$2$3
- Pattern type: Regular Expression
- Description: Always show the desktop site of a webpage
AMP redirect
- Example URL:
https://www.google.com/amp/www.example.com/amp/document
- Include pattern:
^(?:https?://)www.(?:google|bing).com/amp/(?:s/)?(.*)
- Redirect to:
https://$1
- Pattern type: Regular Expression
- Description: AMP is bad: https://80×24.net/post/the-problem-with-amp/
Doubleclick escaper
- Example URL:
https://ad.doubleclick.net/ddm/trackclk/N135005.2681608PRIVATENETWORK/B20244?https://www.example.com
- Include pattern:
^(?:https?://)ad.doubleclick.net/.*\?(http?s://.*)
- Redirect to:
$1
- Pattern type: Regular Expression
- Description: Remove doubleclick link tracking / fix problems with doubleclick host based blocking
YouTube Shorts to YouTube
- Example URL:
https://www.youtube.com/shorts/video-id
- Include pattern:
^(?:https?://)(?:www.)?youtube.com/shorts/([a-zA-Z0-9_-]+)(.*)
- Redirect to:
https://www.youtube.com/watch?v=$1$2
- Pattern type: Regular Expression
- Description: Redirect YouTube Shorts to regular YouTube
Fun with !bangs
What are bangs?: https://duckduckgo.com/bangs
Use DuckDuckGo.com !bangs on Google
- Example URL:
https://www.google.com/search?&ei=-FvkXcOVMo6RRwW5p5DgBg&q=asdfasdf%21+sadfas&oq=%21asdfasdf+sadfas&gs_l=asdfsadfafsgaf
- Include pattern:
^(?:https?://)(?:www.)google\.(?:com|au|de|co\.uk)/search\?(?:.*)?(?:oq|q)=([^\&]*\+)?((?:%21|!)[^\&]*)
- Redirect to:
https://duckduckgo.com/?q=$1$2
- Pattern type: Regular Expression
- Description: Redirect any Google query with a !bang to DDG
Custom DuckDuckGo.com !bangs
DDG !example Base
- Example URL:
https://duckduckgo.com/?q=!
example&get=other
- Include pattern:
^(?:https?://)(?:.*\.)?duckduckgo.com/\?q=(?:%21|!)
example(?=[^\+]|$)(?=\W|$)
- Redirect to:
https://example.com/
- Pattern type: Regular Expression
- Description: Redirect to the base site when !bang is the only search parameter
DDG !example Search
- Example URL:
https://duckduckgo.com/?q=searchterm+!
example+searchterm2&get=other
- Include pattern:
^(?:https?://)(?:.*\.)?duckduckgo.com/\?q=(.*\+)?(?:(?:%21|!)
example)(?:\+([^\&\?\#]*))?(?:\W|$)
- Redirect to:
https://example.com/?query=$1$2
- Pattern type: Regular Expression
- Description: Redirect to custom site search
DDG !ghh git-history
- Example URL:
https://duckduckgo.com/?q=!ghh+https%3A%2F%2Fgithub.com%2Fbabel%2Fbabel%2Fblob%2Fmaster%2Fpackages%2Fbabel-core%2FREADME.md&adfasfasd
- Include pattern:
^(?:https?://)duckduckgo.com/\?q=(?:(?:%21|!)ghh\+)(?:.*)(github|gitlab|bitbucket)(?:\.org|\.com)(.*?(?=\&))
- Redirect to:
https://$1.githistory.xyz$2
- Pattern type: Regular Expression
- Description: Create new !ghh bang that redirects to https://githistory.xyz
- Advanced:
- Process matches: URL decode
使用 Redirector 重導網頁的解法, 遇到chrome 瀏覽器重開之後的第一次進入 ptt 還是需要手動按一次 “已滿18歲”, 所以我移掉 Redirector 網頁擴充元件了.
另一個作法是直接在網頁中執行 javascript, 你需要在 chrome 瀏覽器安裝下面的網頁擴充元件:
Custom JavaScript for Websites 2
https://chrome.google.com/webstore/detail/custom-javascript-for-web/ddbjnfjiigjmcpcpkmhogomapikjbjdk
使用網頁擴充元件的好處是在手機與平板的瀏覽器上也可以使用.
執行方法
1:先連到 ptt 的網站,
2:執行 CJS extension,
3:輸入下面的 javascript 腳本:
const el_btn = document.querySelector("button[type='submit'][value='yes']");
if(el_btn) { el_btn.click();}
4:按 Save (存檔).
Q: ptt 的這個自動化功能,可以使用 adblock plus 來處理嗎?
A: Max有挑戰過,但失敗,試不出來,因為 adblock 無法像 CJS 一樣 inject javascript, 相對 adblock plus 安全性會較高,同時也失去部份的功能性。