You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-7Lines changed: 4 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,19 @@
1
-
# tldr-extension-browser
2
-
[](https://github.com/piraces/tldr-extension-browser/actions/workflows/chrome-publish.yml)
1
+
# tldr pages browser extension
3
2
[](https://github.com/piraces/tldr-extension-browser/actions/workflows/artifacts-zip.yml)
4
3
5
4
6
5
📚 A browser extension for [tldr-pages](https://github.com/tldr-pages/tldr).
7
6
8
-
🚧 **There is [work in progress](https://github.com/piraces/tldr-extension-browser/projects/1) for this extension** 🚧
7
+
👷♂️ There is **[work in progress](https://github.com/piraces/tldr-extension-browser/projects/1) for this extension**
9
8
10
9
**Feel free to contribute 😀!!**
11
10
12
11
## Download
13
12
14
-
**Note:** The extension is being reviewed by the Chrome Store and Firefox Browser Add-ons and should be published in a near future.
15
-
16
13
**Get the extension:**
17
14
- For Edge: [https://microsoftedge.microsoft.com/addons/detail/tldr-pages/hbplonhehblpcghgkhnjepdbohbpkoak](https://microsoftedge.microsoft.com/addons/detail/tldr-pages/hbplonhehblpcghgkhnjepdbohbpkoak)
18
-
-🚧 For Chrome (pending review): [in the Chrome Store](https://chrome.google.com/webstore/search/tldr-pages). 🚧
19
-
-🚧 For Firefox (pending review): [Firefox Browser Add-ons](https://addons.mozilla.org/es/firefox/addon/tldr-pages/) 🚧
15
+
- For Chrome: [in the Chrome Store](https://chrome.google.com/webstore/detail/tldr-pages/fcccijijdgmmcjnifgdhcmepnkcdingf).
16
+
- For Firefox: [Firefox Browser Add-ons](https://addons.mozilla.org/es/firefox/addon/tldr-pages/).
constdefaultNotFoundMessageHTML='<div class="not-found"><p class="large">😱</p><p>Page Not Found!</p><p>Submit a pull request to: <a target="_blank" href="https://github.com/tldr-pages/tldr">https://github.com/tldr-pages/tldr</a></p></div>';
top: `${newtop+195}px`// newtop + height of tooltip
91
+
left: `${(rect.left)+arrowOffset}px`,
92
+
top: `${newtop+tooltipHeight}px`
77
93
}
78
-
)
94
+
);
79
95
80
96
// Create markdown and append to tooltip
81
-
letmarkdown=null
82
-
if(content.trim()==='404: Not Found'){
83
-
markdown='<div class="not-found"><p class="large">😱</p><p>Page Not Found!</p><p>Submit a pull request to: <a target="_blank" href="/tldr-pages/tldr">https://github.com/tldr-pages/tldr</a></p></div>'
97
+
letmarkdown=null;
98
+
if(content.trim()===defaultErrorResponse){
99
+
markdown=defaultNotFoundMessageHTML;
84
100
}else{
85
101
if(isMarked){
86
-
markdown=content
102
+
markdown=content;
87
103
}else{
88
-
markdown=marked(content)
104
+
markdown=marked(content);
89
105
}
90
106
}
91
107
92
-
currentContent=markdown
108
+
currentContent=markdown;
93
109
94
-
letmarkdownContent=document.createElement('div')
95
-
markdownContent.innerHTML=markdown
96
-
markdownContent.className+='tldr-chrome'
97
-
tooltip.appendChild(markdownContent)
110
+
letmarkdownContent=document.createElement('div');
111
+
markdownContent.innerHTML=markdown;
112
+
markdownContent.className+=tooltipId;
113
+
tooltip.appendChild(markdownContent);
98
114
}
99
115
}
100
116
101
117
// removes the tooltip, arrow and content
102
118
functionremoveTooltip(){
103
119
if(tooltip!=null){
104
-
tooltip.parentNode.removeChild(tooltip)
105
-
tooltip=null
106
-
arrow.parentNode.removeChild(arrow)
107
-
arrow=null
108
-
currentContent=null
120
+
tooltip.parentNode.removeChild(tooltip);
121
+
tooltip=null;
122
+
arrow.parentNode.removeChild(arrow);
123
+
arrow=null;
124
+
currentContent=null;
109
125
}
110
126
}
111
127
112
128
// Ensures the tldr tooltip does not close if clicked on
113
129
window.onmousedown=(mouseDownEvent)=>{
114
130
letisPopup=false
115
131
mouseDownEvent.path.forEach((elementInPath)=>{
116
-
if(elementInPath.id==='tldr-chrome')isPopup=true
132
+
if(elementInPath.id===tooltipId){
133
+
isPopup=true;
134
+
}
117
135
})
118
136
119
137
if(!isPopup){
120
-
removeTooltip()
138
+
removeTooltip();
121
139
}
122
140
}
123
141
@@ -129,24 +147,24 @@ function generateCommandList (callback) {
129
147
130
148
fetch(apiContentURL)
131
149
.then((response)=>{
132
-
returnresponse.json()
150
+
returnresponse.json();
133
151
})
134
152
.then(data=>{
135
-
letdoc
153
+
letdoc;
136
154
for(docofdata){
137
-
commandList.push(doc.name.split('.')[0])
155
+
commandList.push(doc.name.split('.')[0]);
138
156
}
139
157
140
-
callback()
158
+
callback();
141
159
})
142
160
}
143
161
144
162
// Checks if a command in pre tags is available in the TLDR github repo
145
163
functioncheckCode(){
146
164
generateCommandList(()=>{
147
-
lettag
148
-
letword
149
-
letpreTags=document.getElementsByTagName('pre')
165
+
lettag;
166
+
letword;
167
+
letpreTags=document.getElementsByTagName('pre');
150
168
for(tagofpreTags){
151
169
for(wordoftag.innerText.split(' ')){
152
170
if(commandList.includes(word.toLowerCase())){
@@ -159,10 +177,10 @@ function checkCode () {
159
177
160
178
// Deletes the tooltip and resizes when window is resized.
0 commit comments