Cov txheej txheem:

Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau: 6 Cov Kauj Ruam
Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau: 6 Cov Kauj Ruam

Video: Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau: 6 Cov Kauj Ruam

Video: Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau: 6 Cov Kauj Ruam
Video: Creating a Virtual Environment within a Jupyter Notebook! 2024, Hlis ntuj nqeg
Anonim
Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau
Chrome Web Extension - Tsis Muaj Kev Paub Ua Ntej Yuav Xav Tau

Chrome Extensions yog cov haujlwm me me uas tsim los txhim kho cov neeg siv tshawb nrhiav. Yog xav paub ntxiv txog chrome txuas ntxiv mus rau

Txhawm rau ua Chrome Web Extension, yuav tsum muaj coding, yog li nws muaj txiaj ntsig zoo los tshuaj xyuas HTML, JavaScript, thiab CSS ntawm lub vev xaib hauv qab no:

www.w3schools.com/default.asp (w3 cov tsev kawm ntawv yog lub vev xaib zoo rau cov peev txheej coding)

Tsis paub yuav ua li cas? Tsis txhob txhawj xeeb, qhov kev qhia no yuav pab coj txoj hauv kev.

Qhov zoo tshaj plaws ntawm Chrome txuas ntxiv yog tias lawv tuaj yeem kho tau. Nws tsis yog ib yam tshwj xeeb uas tuaj yeem ua tiav, yog li muaj tswv yim.

Khoom siv

Cov khoom siv uas xav tau yog hauv qab no:

  • Lub khoos phis tawj nrog cov ntawv sau (Kuv siv Notepad)
  • Google Chrome

Thiab tag nrho cov!

Kauj ruam 1: Tsim Cov Ntawv Teev Npe

Tsim Cov Ntawv Teev Npe
Tsim Cov Ntawv Teev Npe

Ua ntej, tsim daim nplaub tshev los tuav tag nrho cov ntaub ntawv, thiab npe nws 'txuas ntxiv'. Lub npe tuaj yeem hloov pauv tom qab yog xav tau.

Kauj ruam 2: Tsim Manifest File thiab Code It

Tsim Cov Ntaub Ntawv Tshaj Tawm thiab Code Nws
Tsim Cov Ntaub Ntawv Tshaj Tawm thiab Code Nws
Tsim Cov Ntaub Ntawv Tshaj Tawm thiab Code Nws
Tsim Cov Ntaub Ntawv Tshaj Tawm thiab Code Nws

Cov ntaub ntawv tshwm sim yog ib feem tseem ceeb heev ntawm kev txuas ntxiv. Nws qhia qhov txuas ntxiv raws nraim qhov yuav tsum ua thiab yog. Cov ntaub ntawv tshaj tawm tau muab tso rau hauv JSON. Thawj kauj ruam yog qhib cov ntawv sau thiab khaws cov ntaub ntawv tshiab li 'manifest.json'.

Tom ntej no ntaus cov ntawv hauv qab no:

{

"lub npe": "Thawj qhov txuas ntxiv", "version": "1.0", "kev piav qhia": "Kuv tuaj yeem sau tus lej txuas ntxiv", "manifest_version": 2, "browser_action": {"default_title": "Thawj qhov txuas ntxiv"}}

Nco qab tus lej tom qab tus nqi!

Tom qab qhov no tau ntaus, khaws cov ntaub ntawv tshwm sim thiab mus rau chrome: // txuas ntxiv (Chrome yuav tsum tau siv ua qhov browser rau qhov no). Ib zaug ntawm chrome: // txuas ntxiv, qhib hom tsim tawm. Tom qab ntawd, nyem lub pob 'Load unpacked' thiab xaiv 'nplaub tshev' txuas ntxiv.

drum roll thov …

Yay! Qhov ntawd yog qhov txuas ntxiv, tshwj tsis yog… nws zoo li tho txawv. Nws tsis ua dab tsi li tam sim no, tab sis tsis ntev nws yuav txias heev.

Kauj Ruam 3: Tsim cov Icons thiab hloov kho Manifest

Tsim cov Icons thiab hloov kho Manifest
Tsim cov Icons thiab hloov kho Manifest

Ib lub vev xaib uas ua haujlwm zoo rau kos duab yog https://www.piskelapp.com/. Muaj lwm qhov kev kos duab muaj rau siv, ib yam nkaus. Cov cim yuav tsum yog plaub fab. Txoj haujlwm no yuav siv 16x16, 32x32, 48x48, thiab 128x128 lub cim. Thaum lub cim tau tsim, ua daim nplaub tshev hu ua 'duab' hauv daim nplaub tshev txuas ntxiv thiab muab lub cim tso rau hauv daim nplaub tshev ntawd. Nws yuav yog lub tswv yim zoo rau npe lub duab raws li nws qhov loj me. Piv txwv li, 'icon32.png'. Txoj cai tshiab yog hauv qab no:

{

"lub npe": "Thawj qhov txuas ntxiv", "version": "1.0", "kev piav qhia": "Kuv tuaj yeem sau tus lej txuas ntxiv", "manifest_version": 2, "browser_action": {"default_title": "Thawj qhov txuas ntxiv", " default_icon ": {" 16 ":" images/icon16-p.webp

Rau kev siv ntawm tus lej pom, mus rau

Kauj ruam 4: Ntxiv Popup

Ntxiv Popup
Ntxiv Popup
Ntxiv Popup
Ntxiv Popup

Qhov txuas ntxiv no yuav muaj popup. Qhov tshwm sim yog HTML (Hypertext Markup Language) cov ntaub ntawv, yog li nws yog qhov zoo kom kawm paub pib ntawm HTML, CSS, thiab JavaScript ua ntej.

Ua ntej, khaws ib daim ntawv ua 'popup.html' cov ntawv hauv daim nplaub tshev txuas ntxiv.

Tom ntej no, kho cov ntaub ntawv qhia pom 'popup.html' thaum nws tau nyem. Txoj cai tshiab yog hauv qab no:

{

"lub npe": "Thawj qhov txuas ntxiv", "version": "1.0", "kev piav qhia": "Kuv tuaj yeem sau tus lej txuas ntxiv", "manifest_version": 2, "browser_action": {"default_title": "Thawj qhov txuas ntxiv", " default_icon ": {" 16 ":" images/icon16-p.webp

Tsis txhob hnov qab tus comma!

Tam sim no, yog tias cov lej HTML hauv qab no tau ntxiv rau popup.html, tom qab ntawd nws yuav qhia 'Nyob Zoo Ntiaj Teb' thaum nyem.

Nyob Zoo Ntiaj Teb

Kauj Ruam 5: Ua Kom Nws Zoo Zoo thiab Ua Nws Sib Tham

Ua kom Nws Saib Zoo thiab Ua Nws Sib Tham
Ua kom Nws Saib Zoo thiab Ua Nws Sib Tham
Ua kom Nws Saib Zoo thiab Ua Nws Sib Tham
Ua kom Nws Saib Zoo thiab Ua Nws Sib Tham

Yog tias kab HTML yooj yim tau ntaus, tom qab ntawd nws tau txais qhov tsawg kawg nkaus liab qab ua tiav. Yog tias CSS (Cascading Style Sheets) tau ntxiv, tom qab ntawd nws yuav zoo li txias dua, thiab yog tias JavaScript tau ntxiv, tom qab ntawd nws tuaj yeem sib tham tau ntau dua. Phau ntawv qhia no yuav tsis piav qhia ntxaws piav qhia HTML, JavaScript, thiab CSS, tab sis muaj ntau cov peev txheej hauv online. Hauv qab no yog cov cai rau qhov yooj yim 'Nyob Zoo Hauv Ntiaj Teb' txoj haujlwm, tom qab ntawd muaj cov xim zoo nkauj dua, raws li:

Nyob Zoo Ntiaj Teb

Nyob Zoo Ntiaj Teb

#nyob zoo {keeb kwm yav dhau xim: #000000; xim: #ff0000; ciam teb: 8px pib #86a3b2; ciam teb-vojvoog: 50px; hloov pauv: tig (57deg); duav: 10px; neeg siv-xaiv: tsis muaj; tus cursor: crosshair; kev hloov pauv: hloov 2s; } #hello: hover {hloov pauv: tig (-417deg); }

Qhov piv txwv thib ob no tuaj yeem ua rau tsis meej pem, rau tus pib. Tab sis, qhov no yog qhia koj li cas tseem ceeb CSS yog rau ib qho program/txuas ntxiv. Tam sim no yuav yog lub sijhawm zoo los so thiab kawm qee qhov HTML5 coding thiab siv developer.chrome.com rau qee qhov siv. Nws yuav siv qee lub sijhawm, tab sis tuaj yeem ua qhov txuas ntxiv tau zoo.

Kauj Ruam 6: Tshaj Tawm Nws rau Chrome Web Store

Tshaj Tawm Nws rau Chrome Web Store
Tshaj Tawm Nws rau Chrome Web Store
Tshaj Tawm Nws rau Chrome Web Store
Tshaj Tawm Nws rau Chrome Web Store

Yog tias qee leej tau ua qhov txuas ntxiv zoo tiag tiag thiab lawv xav qhia nws rau ntiaj teb, tom qab ntawd lawv tuaj yeem tshaj tawm nws. Ntawd yog, tom qab tag nrho, lub ntsiab lus ntawm kev txuas ntxiv. Phau ntawv qhia no tsuas yog sim piav qhia cov ntaub ntawv tshwm sim, thiab koj yuav siv nws li cas, thiab nws tsuas yog muaj 'Hello World' program.

Thawj qhov uas yuav tsum ua kom nthuav dav rau pej xeem yog ua cov ntawv tais ceev tseg rau hauv zip file. Qhov thib ob uas yuav tsum ua yog mus rau https://chrome.google.com/webstore/category/extensions thiab nkag mus rau hauv google account. Tom qab ntawd, nyem rau ntawm lub pob iav teeb tsa thiab tom qab ntawd nyem rau ntawm 'developer dashboard'. Nias lub pob 'Khoom Tshiab' txhawm rau rub cov ntawv zip. Thaum muaj, nws yog qhov yuav tsum tau hloov kho Cov Ntawv Teev Npe, Tsis pub twg paub, thiab tus nqi. Qhov txuas ntxiv tuaj yeem luam tawm tau yooj yim yog tias nws tau xa rau kev tshuaj xyuas.

Tam sim no qhov txuas ntxiv tau ua tiav, txuas ntxiv mus rau code!

Pom zoo: