|
1 | 1 | /** @format */
|
2 | 2 | console.log("Medium parser loaded");
|
3 | 3 |
|
| 4 | +const ignoreURLs = [ |
| 5 | + "/me/lists", |
| 6 | + "/me/lists/saved", |
| 7 | + "/me/list/highlights", |
| 8 | + "/me/lists/reading-history", |
| 9 | + "/me/stories/public", |
| 10 | + "/me/stories/responses", |
| 11 | + "/me/stories/drafts", |
| 12 | + "/me/stats", |
| 13 | + "/me/settings", |
| 14 | + "/me/following", |
| 15 | + "/me/settings", |
| 16 | + "/me/settings/publishing", |
| 17 | + "/me/settings/notifications", |
| 18 | + "/me/settings/membership", |
| 19 | + "/me/settings/security", |
| 20 | + "/me/notifications", |
| 21 | + "/plans", |
| 22 | + "/mastodon", |
| 23 | + "/verified-authors", |
| 24 | + "/partner-program", |
| 25 | + "/gift-plans", |
| 26 | + "/new-story", |
| 27 | + "/m/signin", |
| 28 | +]; |
| 29 | + |
4 | 30 | function init() {
|
5 | 31 | if (checkIfGoogleWebCache()) {
|
6 |
| - formatGoogleWebCache(); |
| 32 | + return formatGoogleWebCache(); |
7 | 33 | }
|
8 | 34 |
|
9 | 35 | checkIfItIsMediumBlog();
|
@@ -62,25 +88,38 @@ function runMedium(url) {
|
62 | 88 | const root = document.getElementById("root");
|
63 | 89 | root.style.position = "relative";
|
64 | 90 |
|
65 |
| - if (u.pathname.split("/").filter((e) => e).length >= 1) { |
| 91 | + if ( |
| 92 | + ignoreURLs.indexOf(u.pathname) == -1 && |
| 93 | + u.pathname.split("/").filter((e) => e).length >= 1 |
| 94 | + ) { |
66 | 95 | // get the title
|
67 | 96 |
|
68 | 97 | var leftDiv = document.createElement("div"); //Create left div
|
69 | 98 | leftDiv.id = "medium-parser"; //Assign div id
|
70 | 99 | leftDiv.setAttribute(
|
71 | 100 | "style",
|
72 |
| - "position:absolute;z-index:9999999;top:150px;right:150px;" |
| 101 | + "position:absolute;z-index:1;top:150px;right:150px;" |
73 | 102 | ); //Set div attributes
|
74 | 103 | a = document.createElement("a");
|
75 | 104 | a.href = `http://webcache.googleusercontent.com/search?q=cache:${url}&strip=0&vwsrc=1&referer=medium-parser`; // Instead of calling setAttribute
|
76 |
| - a.innerHTML = "Read full article"; // <a>INNER_TEXT</a> |
| 105 | + a.innerHTML = "Read from Google Cache"; |
77 | 106 | a.setAttribute(
|
78 | 107 | "style",
|
79 |
| - "padding:10px 25px; color:white; background: #2c3e50; display:block;" |
| 108 | + "padding:14px 25px; color:white; background: #242424; display:block;text-align:center;" |
80 | 109 | ); //Set div attributes
|
81 | 110 | a.setAttribute("target", "_blank"); //Set div attributes
|
82 | 111 |
|
| 112 | + archive = document.createElement("a"); |
| 113 | + archive.href = `https://archive.is?url=${url}&run=1&referer=medium-parser`; // Instead of calling setAttribute |
| 114 | + archive.innerHTML = "Read from Archive.is"; |
| 115 | + archive.setAttribute( |
| 116 | + "style", |
| 117 | + "padding:14px 25px; color:white; background: #242424; display:block; margin-top:10px;text-align:center;" |
| 118 | + ); //Set div attributes |
| 119 | + archive.setAttribute("target", "_blank"); //Set div attributes |
| 120 | + |
83 | 121 | leftDiv.appendChild(a); // Append the link to the div
|
| 122 | + leftDiv.appendChild(archive); |
84 | 123 | root.appendChild(leftDiv); // A
|
85 | 124 | } else {
|
86 | 125 | // remove the element
|
|
0 commit comments