用 Go 語言來編寫 Chrome 擴展:Gopherjs Chrome Bindings
該項目可以讓你用 Go 語言來編寫 Chrome 擴展。在Gopherjs transpiler的幫助下,可以用Go編寫能被轉換為JS并能運行在瀏覽器的代碼。此庫以簡單而直觀的方式包括了與Chrome JS API交互的必要綁定, 以便你能夠用Go編寫Chrome插件和Chrome OS應用
Write Chrome extensions in Go!
With the help of the Gopherjs transpiler, you can now write Go code which will be converted into javascript and run in the browser. This library contains the necessary bindings to interact with the Chrome Javascript API in an easy and intuitive way so that you can write Chrome Extensions and Chrome OS apps in Go.
示例代碼:package main import ( "strconv" "honnef.co/go/js/dom" "github.com/fabioberger/chrome" ) func main() { c := chrome.NewChrome() tabDetails := chrome.Object{ "active": false, } c.Tabs.Create(tabDetails, func(tab chrome.Tab) { notification := "Tab with id: " + strconv.Itoa(tab.Id) + " created!" dom.GetWindow().Document().GetElementByID("notification").SetInnerHTML(notification) }) }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!