Keyboard Event:在網頁上自定義快速鍵
source link: https://blog.gslin.org/archives/2024/01/22/11608/keyboard-event%ef%bc%9a%e5%9c%a8%e7%b6%b2%e9%a0%81%e4%b8%8a%e8%87%aa%e5%ae%9a%e7%be%a9%e5%bf%ab%e9%80%9f%e9%8d%b5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Keyboard Event:在網頁上自定義快速鍵
先前寫了一堆 userscript 針對不同的網站加上快速鍵 (像是翻下一頁或是上一頁):
然後發現太多重複的事情了,就寫成 Chrome 的 extension 了:「Keyboard Event」,程式碼在 GitHub 上有放:「gslin/keyboard-event」,不信任一致性的話也可以用 Chrome extension source viewer 直接看 chrome web store 上面放的版本。
這個 extension 的想法是設定 hostname、path 以及按鍵,接著設定按鍵按下後會觸發的 DOM element (用 CSS selector 選) 與 DOM event (像是 mouseover
這樣的 event 字串)。
而其中 click
event 常常不會動 (對應實際的呼叫是 element.dispatchEvent(new Event('click'))
),在 debug 時發現需要用 click()
(對應實際的呼叫是 element.click()
),所以有特別接受 click()
這個字串。
這個舉個例子,我有一組設定是:
www.instagram.com .* < div[role="dialog"] button[aria-label="Go back"] click() www.instagram.com .* > div[role="dialog"] button[aria-label="Next"] click()
在瀏覽器上面看 Instagram 的照片時可以用 < 與 > 快速切換照片。
另外設定的部分支援 chrome.storage 的 browser sync,對於有多瀏覽器時會自動同步設定檔,不用每一台都設定一次...
這算是第一次寫 Manifest V3 的 extension (先前都是 V2),本來想用 Vue.js 處理設定頁 options.html
,但遇到了 CSP 的問題,在 Manifest V3 上面無法設定 unsafe-eval
,於是 Vue.js 只能用 runtime 版本,喪失了 template 好用的地方...
後來決定回頭用 jQuery + jQuery UI (用 sortable),然後自己處理一堆 data 更新時頁面的變化,一整個 2010 年老人味都出來了...
但這樣至少會動,先跑一陣子看看...
Related
在網頁行動版的 Twitter 上增加快速鍵
現在 Twitter 的網頁版愈做愈慢,於是有不少人在桌機上是用提供給行動裝置的版本瀏覽 (也就是 mobile.twitter.com 這個站),但這個站的功能其實頗陽春。 而 sindresorhus/refined-twitter 這個專案則在行動版本上面增加了許多快速鍵,在 Google Chrome 上可以透過 Store 安裝:「Refined Twitter」。 之前沒用過行動版的網站,這速度快好多啊...
May 6, 2016In "Browser"
Gmail 刪除信件的快速鍵
Gmail 刪除信件的功能一直都沒有快速鍵,結果有人發現在 Opera 9.1 可以用 End 鍵做到:'Secret' Gmail Delete Mail Keyboard Shortcut。 因為其他所有的 Browser 都做不到,所以我猜可以用 End 在 Opera 9.1 裡面刪除的功能應該是 bug 造成的吧 XD Google 裡的某些人大概又開始在暗幹 Opera 了... XD
January 24, 2007In "Browser"
Optimus 的三鍵鍵盤
在二月的時候在 鍵盤 這篇提到 Optimus Mini 的預購,剛剛終於在 Slashdot 上看到 Optimus Mini 三鍵鍵盤 的 review 了:Optimus Mini Three OLED keyboard reviewed,原文在這:Optimus Mini Three: OLED keyboard reviewed。 (引用二月那篇的圖,讓沒看過 & 忘記的人看一下這個三鍵鍵盤有多華麗... XD) 直接引用第三頁的說明,這支鍵盤其實裡面就有個小型的處理器以及記憶體: Apart from the obligatory resistors and capacitors, we discover three big chips. In the centre of the board is a PIC18F8722…
October 1, 2006In "Computer"
Author Gea-Suan LinPosted on January 22, 2024January 22, 2024Categories Browser, Computer, GoogleChrome, Murmuring, Network, Programming, SoftwareTags chrome, dom, element, event, extension, html, keyboard
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Notify me of follow-up comments by email.
Notify me of new posts by email.
To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)
Post navigation
Recommend
-
14
網頁內嵌 JSON 注意事項 2021-01-07 08:29 PM 0 2,468 在輸出網頁時內嵌 JSON 轉成 JavaScript 物件是我愛用的手法,這點之前有
-
9
Web data scraping Company/網絡數據抓取公司
-
7
為第一次使用網頁顯示「新手提示」之懶人工具 2021-04-01 10:25 PM 1 1,574 寫網頁的人總夢想著自己寫的介面夠簡單夠直覺,不需說明文件,使用者模索兩下就能上...
-
7
將 HTML 圖文網頁轉成 ePub 電子書試過純手工打造 ePub 電子書,寫過程式半自動轉換。前陣子試了另一種作法 - 用現成工...
-
6
網頁「新手提示」懶人工具 1.1 版 2021-04-04 08:20 AM 0 249 前幾天分享了我的私房「網頁新手...
-
6
keycloak~管理平台的查询bug与自定rest中文检索 ...
-
5
CWP如何自定义子域名文件夹目录路径?编辑vhosts文件 https://www.chenweiliang.com/cwl-28218.html
-
6
9月起使用自定产品页创建的广告系列需要与iTC账户关联-鸟哥笔记 首页 >...
-
2
2022年1月,Apple Ads正式接入自定义产品页功能(Custom Product Pages,简称 CPP)。通过这项功能,开发者借助CPP向用户展示不同的活动、节目等内容 ,实现“千人千面”。 在上线的这一年时间里,
-
1
React中内置的hooks无法满足我们的业务,我们应该如何封装一些适合的hooks呢? 我们在之前的文章 如...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK