From 27bccdc536bb95f4f031d0396a0977c7c9f56e73 Mon Sep 17 00:00:00 2001 From: Monzurul Islam Date: Tue, 26 Dec 2023 19:06:27 +0900 Subject: [PATCH 1/3] code refactor and freedium source added --- app.js | 113 ++++++++++++++++++++++++++------------------------------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/app.js b/app.js index 119ba25..47323c3 100644 --- a/app.js +++ b/app.js @@ -39,9 +39,6 @@ init(); // checks if the page is google web cache and referred by this extension function checkIfGoogleWebCache() { - // console.log( - // "Checking if this site is google webcache and referred by medium-parser extension" - // ); const url = new URL(document.URL); if ( @@ -88,7 +85,7 @@ function handleURLChange() { } function runMedium(url) { - // check the url + // check the url const u = new URL(url); // check if it is a page @@ -99,59 +96,38 @@ function runMedium(url) { ignoreURLs.indexOf(u.pathname) == -1 && u.pathname.split("/").filter((e) => e).length >= 1 ) { - // get the title - - var leftDiv = document.createElement("div"); //Create left div - leftDiv.id = "medium-parser"; //Assign div id + var leftDiv = document.createElement("div"); + leftDiv.id = "medium-parser"; leftDiv.setAttribute( "style", "position:absolute;z-index:1;top:150px;right:150px;" - ); //Set div attributes - a = document.createElement("a"); - a.href = `http://webcache.googleusercontent.com/search?q=cache:${url}&strip=0&vwsrc=1&referer=medium-parser`; // Instead of calling setAttribute - a.innerHTML = "Open in Google Cache"; - a.setAttribute( - "style", - "padding:14px 25px; color:white; background: #242424; display:block;text-align:center;" - ); //Set div attributes - a.setAttribute("target", "_blank"); //Set div attributes - - archive = document.createElement("a"); - archive.href = `https://archive.today?url=${url}&run=1&referer=medium-parser`; // Instead of calling setAttribute - archive.innerHTML = "Open in Archive"; - archive.setAttribute( - "style", - "padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;" - ); //Set div attributes - archive.setAttribute("target", "_blank"); //Set div attributes - - // old API - oldAPI = document.createElement("a"); - oldAPI.href = `https://medium-parser.vercel.app/?url=${url}`; // Instead of calling setAttribute - oldAPI.innerHTML = "Open in Proxy API"; - oldAPI.setAttribute( - "style", - "padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;" - ); //Set div attributes - oldAPI.setAttribute("target", "_blank"); //Set div attributes - - // add readmedium.com - readMedium = document.createElement("a"); - readMedium.href = `https://readmedium.com/${url}`; // Instead of calling setAttribute - readMedium.innerHTML = "Open in Read-Medium"; - readMedium.setAttribute( - "style", - "padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;" - ); //Set div attributes - readMedium.setAttribute("target", "_blank"); //Set div attributes + ); + + let buttons = [ + createButton( + "Open in Google Cache", + `http://webcache.googleusercontent.com/search?q=cache:${url}&strip=0&vwsrc=1&referer=medium-parser` + ), + createButton("Open in Read-Medium", `https://readmedium.com/en/${url}`), + createButton("Open in Freedium", `https://freedium.cfd/${url}`), + createButton( + "Open in Archive", + `https://archive.today?url=${url}&run=1&referer=medium-parser` + ), + createButton( + "Open in Proxy API", + `https://medium-parser.vercel.app/?url=${url}` + ), + createMessageElement(), + createSupportElement(), + ]; messageEl = createMessageElement(); - leftDiv.appendChild(a); // Append the link to the div - leftDiv.appendChild(readMedium); - leftDiv.appendChild(archive); - leftDiv.appendChild(oldAPI); - leftDiv.appendChild(messageEl); + buttons.forEach((button) => { + leftDiv.appendChild(button); + }); + root.appendChild(leftDiv); // A } else { // remove the element @@ -208,20 +184,33 @@ function createMessageElement() { "style", "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;" ); - - // cross el - // crossEl = document.createElement("div"); - // crossEl.innerHTML = "✕"; - // crossEl.setAttribute( - // "style", - // "position: absolute;right: -1px;top: -1px;background: #242424;padding: 0px 4px;margin: 0; color: white;cursor: pointer;" - // ); - // crossEl.addEventListener("click", removeMessageEl); - - // messageEl.appendChild(crossEl); return messageEl; } +function createSupportElement() { + btnEl = document.createElement("div"); + btnEl.innerHTML = + "Having an issue ? Open a ticket"; + btnEl.setAttribute( + "style", + "padding:2px 4px; color:#242424; display:block; text-align:left;max-width: 212px;font-size: 0.83em; margin-top:10px; position:relative;" + ); + return btnEl; +} + function removeMessageEl(e) { e.target.parentNode.remove(); } + +// create the button UI +function createButton(text, url) { + btnEl = document.createElement("a"); + btnEl.href = url; + btnEl.innerHTML = text; + btnEl.setAttribute( + "style", + "padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;" + ); + btnEl.setAttribute("target", "_blank"); + return btnEl; +} From f50ef4a2a4087790f4f3540c744df2e0945b2b9d Mon Sep 17 00:00:00 2001 From: Monzurul Islam Date: Tue, 26 Dec 2023 19:08:14 +0900 Subject: [PATCH 2/3] update readme --- README.md | 2 ++ app.js | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef03446..f11ec44 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Your contribution allows me to spend more time making this kind of extension/pro ### Updates +#### 1.5.0 +Added support for [https://freedium.cfd//](https://freedium.cfd//) #### 1.4.0 Added support for [https://readmedium.com/](https://readmedium.com/) #### 1.3.2 diff --git a/app.js b/app.js index 47323c3..5fdd5c7 100644 --- a/app.js +++ b/app.js @@ -122,8 +122,6 @@ function runMedium(url) { createSupportElement(), ]; - messageEl = createMessageElement(); - buttons.forEach((button) => { leftDiv.appendChild(button); }); From 7714ef91f4cd746631e70f1832e81fbfc439dfee Mon Sep 17 00:00:00 2001 From: Monzurul Islam Date: Tue, 26 Dec 2023 19:12:09 +0900 Subject: [PATCH 3/3] update manifest --- README.md | 4 ++++ manifest.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f11ec44..336485b 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ Your contribution allows me to spend more time making this kind of extension/pro ### Updates #### 1.5.0 Added support for [https://freedium.cfd//](https://freedium.cfd//) + +Added support link to resolve the issues. + +Code refactoring #### 1.4.0 Added support for [https://readmedium.com/](https://readmedium.com/) #### 1.3.2 diff --git a/manifest.json b/manifest.json index 22e8155..193396e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Medium parser", - "version": "1.4.0", + "version": "1.5.0", "description": "Unlocks the whole medium article on the go.", "icons": { "16": "img/icon16.jpg",