Skip to content

Commit 48eb2d1

Browse files
authored
Merge pull request #17 from Xatta-Trone/Feat/add-freedium-source
Feat/add freedium source
2 parents da7ac50 + 7714ef9 commit 48eb2d1

File tree

3 files changed

+58
-65
lines changed

3 files changed

+58
-65
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Your contribution allows me to spend more time making this kind of extension/pro
4848

4949

5050
### Updates
51+
#### 1.5.0
52+
Added support for [https://freedium.cfd//](https://freedium.cfd//)
53+
54+
Added support link to resolve the issues.
55+
56+
Code refactoring
5157
#### 1.4.0
5258
Added support for [https://readmedium.com/](https://readmedium.com/)
5359
#### 1.3.2

app.js

Lines changed: 51 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ init();
3939

4040
// checks if the page is google web cache and referred by this extension
4141
function checkIfGoogleWebCache() {
42-
// console.log(
43-
// "Checking if this site is google webcache and referred by medium-parser extension"
44-
// );
4542
const url = new URL(document.URL);
4643

4744
if (
@@ -88,7 +85,7 @@ function handleURLChange() {
8885
}
8986

9087
function runMedium(url) {
91-
// check the url
88+
// check the url
9289
const u = new URL(url);
9390

9491
// check if it is a page
@@ -99,59 +96,36 @@ function runMedium(url) {
9996
ignoreURLs.indexOf(u.pathname) == -1 &&
10097
u.pathname.split("/").filter((e) => e).length >= 1
10198
) {
102-
// get the title
103-
104-
var leftDiv = document.createElement("div"); //Create left div
105-
leftDiv.id = "medium-parser"; //Assign div id
99+
var leftDiv = document.createElement("div");
100+
leftDiv.id = "medium-parser";
106101
leftDiv.setAttribute(
107102
"style",
108103
"position:absolute;z-index:1;top:150px;right:150px;"
109-
); //Set div attributes
110-
a = document.createElement("a");
111-
a.href = `http://webcache.googleusercontent.com/search?q=cache:${url}&strip=0&vwsrc=1&referer=medium-parser`; // Instead of calling setAttribute
112-
a.innerHTML = "Open in Google Cache";
113-
a.setAttribute(
114-
"style",
115-
"padding:14px 25px; color:white; background: #242424; display:block;text-align:center;"
116-
); //Set div attributes
117-
a.setAttribute("target", "_blank"); //Set div attributes
118-
119-
archive = document.createElement("a");
120-
archive.href = `https://archive.today?url=${url}&run=1&referer=medium-parser`; // Instead of calling setAttribute
121-
archive.innerHTML = "Open in Archive";
122-
archive.setAttribute(
123-
"style",
124-
"padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;"
125-
); //Set div attributes
126-
archive.setAttribute("target", "_blank"); //Set div attributes
127-
128-
// old API
129-
oldAPI = document.createElement("a");
130-
oldAPI.href = `https://medium-parser.vercel.app/?url=${url}`; // Instead of calling setAttribute
131-
oldAPI.innerHTML = "Open in Proxy API";
132-
oldAPI.setAttribute(
133-
"style",
134-
"padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;"
135-
); //Set div attributes
136-
oldAPI.setAttribute("target", "_blank"); //Set div attributes
137-
138-
// add readmedium.com
139-
readMedium = document.createElement("a");
140-
readMedium.href = `https://readmedium.com/${url}`; // Instead of calling setAttribute
141-
readMedium.innerHTML = "Open in Read-Medium";
142-
readMedium.setAttribute(
143-
"style",
144-
"padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;"
145-
); //Set div attributes
146-
readMedium.setAttribute("target", "_blank"); //Set div attributes
147-
148-
messageEl = createMessageElement();
104+
);
105+
106+
let buttons = [
107+
createButton(
108+
"Open in Google Cache",
109+
`http://webcache.googleusercontent.com/search?q=cache:${url}&strip=0&vwsrc=1&referer=medium-parser`
110+
),
111+
createButton("Open in Read-Medium", `https://readmedium.com/en/${url}`),
112+
createButton("Open in Freedium", `https://freedium.cfd/${url}`),
113+
createButton(
114+
"Open in Archive",
115+
`https://archive.today?url=${url}&run=1&referer=medium-parser`
116+
),
117+
createButton(
118+
"Open in Proxy API",
119+
`https://medium-parser.vercel.app/?url=${url}`
120+
),
121+
createMessageElement(),
122+
createSupportElement(),
123+
];
124+
125+
buttons.forEach((button) => {
126+
leftDiv.appendChild(button);
127+
});
149128

150-
leftDiv.appendChild(a); // Append the link to the div
151-
leftDiv.appendChild(readMedium);
152-
leftDiv.appendChild(archive);
153-
leftDiv.appendChild(oldAPI);
154-
leftDiv.appendChild(messageEl);
155129
root.appendChild(leftDiv); // A
156130
} else {
157131
// remove the element
@@ -208,20 +182,33 @@ function createMessageElement() {
208182
"style",
209183
"padding:2px 4px; color:#242424; display:block; text-align:left;max-width: 212px;font-size: 0.83em;border: 1px solid black; margin-top:10px; position:relative;"
210184
);
211-
212-
// cross el
213-
// crossEl = document.createElement("div");
214-
// crossEl.innerHTML = "✕";
215-
// crossEl.setAttribute(
216-
// "style",
217-
// "position: absolute;right: -1px;top: -1px;background: #242424;padding: 0px 4px;margin: 0; color: white;cursor: pointer;"
218-
// );
219-
// crossEl.addEventListener("click", removeMessageEl);
220-
221-
// messageEl.appendChild(crossEl);
222185
return messageEl;
223186
}
224187

188+
function createSupportElement() {
189+
btnEl = document.createElement("div");
190+
btnEl.innerHTML =
191+
"Having an issue ? <a href='https://github.com/Xatta-Trone/medium-parser-extension/issues/new' target='_blank' style='color: #ff4757;text-decoration: underline;'>Open a ticket</a>";
192+
btnEl.setAttribute(
193+
"style",
194+
"padding:2px 4px; color:#242424; display:block; text-align:left;max-width: 212px;font-size: 0.83em; margin-top:10px; position:relative;"
195+
);
196+
return btnEl;
197+
}
198+
225199
function removeMessageEl(e) {
226200
e.target.parentNode.remove();
227201
}
202+
203+
// create the button UI
204+
function createButton(text, url) {
205+
btnEl = document.createElement("a");
206+
btnEl.href = url;
207+
btnEl.innerHTML = text;
208+
btnEl.setAttribute(
209+
"style",
210+
"padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;"
211+
);
212+
btnEl.setAttribute("target", "_blank");
213+
return btnEl;
214+
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Medium parser",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"description": "Unlocks the whole medium article on the go.",
66
"icons": {
77
"16": "img/icon16.jpg",

0 commit comments

Comments
 (0)