Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachSaucier committed Sep 9, 2016
1 parent 51df38a commit b2c7227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
16 changes: 9 additions & 7 deletions content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ function getArticleDate() {
date = document.body.querySelector('[class^="date"]').innerText;
if(!date && document.body.querySelector('[class*="-date"]'))
date = document.body.querySelector('[class*="-date"]').innerText;
if(!date && document.body.querySelector('[class*="_date"]'))
date = document.body.querySelector('[class*="_date"]').innerText;

// Check to see if there is a date available in the meta, if so get it
if(!date && document.head.querySelector('meta[name^="date"]'))
Expand All @@ -275,7 +277,7 @@ function getArticleDate() {
}

if(date)
return date.replace(/on\s/ig, '').replace(/[<]br[^>]*[>]/gi,'&nbsp;'); // Replace <br> and "on"
return date.replace(/on\s/gi, '').replace(/(?:\r\n|\r|\n)/gi, '&nbsp;').replace(/[<]br[^>]*[>]/gi,'&nbsp;'); // Replace <br>, \n, and "on"

return "Unknown date";
}
Expand Down Expand Up @@ -370,7 +372,7 @@ function getArticleAuthor() {

elem = document.body.querySelector('[class*="author"]');
if(author === null && elem) {
if(elem.innerText.split(/\s+/).length < 5 && elem.innerText.replace(/\s/g,'') !== "") {
if(elem.innerText.split(/\s+/).length < 6 && elem.innerText.replace(/\s/g,'') !== "") {
author = elem.innerText;
}
}
Expand Down Expand Up @@ -533,11 +535,11 @@ function addArticleMeta() {

// Check a couple places for the date, othewise say it's unknown
date.innerHTML = editSVG;
dateContent.innerText = getArticleDate();
dateContent.innerHTML = getArticleDate();
date.appendChild(dateContent);
// Check to see if there is an author available in the meta, if so get it, otherwise say it's unknown
author.innerHTML = editSVG;
authorContent.innerText = getArticleAuthor();
authorContent.innerHTML = getArticleAuthor();
author.appendChild(authorContent);
// Check h1s for the title, otherwise say it's unknown
title.innerHTML = editSVG;
Expand Down Expand Up @@ -827,7 +829,7 @@ function createSimplifiedOverlay() {
}

// If there's no text, grab the whole page
if(globalMostPs.textContent.replace(/\s/g, "") === "")
if(globalMostPs != null && globalMostPs.textContent.replace(/\s/g, "") === "")
globalMostPs = document.body;

// Get the title, author, etc.
Expand Down Expand Up @@ -870,7 +872,7 @@ function createSimplifiedOverlay() {

// If there's no code, format it
if(!isPreNoCode) {
elem.innerHTML = elem.innerHTML.replace(/\n\n/g, '<br/><br/>')
elem.innerHTML = elem.innerHTML.replace(/\n/g, '<br/>')
}
}

Expand Down Expand Up @@ -997,7 +999,7 @@ function continueLoading() {

var isPaused = false,
stylesheetObj = {},
stylesheetVersion = 1.7; // THIS NUMBER MUST BE CHANGED FOR THE STYLESHEETS TO KNOW TO UPDATE
stylesheetVersion = 1.8; // THIS NUMBER MUST BE CHANGED FOR THE STYLESHEETS TO KNOW TO UPDATE
// Detect past overlay - don't show another
if(document.getElementById("simple-article") == null) {
var interval = setInterval(function() {
Expand Down
5 changes: 2 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "Just Read",
"version": "1.0.1",
"version": "1.0.2",
"manifest_version": 2,
"description": "An article formatter for readability. Essentially an attractive and customizable read mode.",
"description": "A customizable read mode extension.",
"homepage_url": "https://github.com/ZachSaucier/Just-Read",
"offline_enabled": true,

Expand Down Expand Up @@ -51,7 +51,6 @@
"required-styles.css",
"default-styles.css",
"page.css",
"dat-gui.js",
"options.js",
"options.css",
"fonts/*"
Expand Down
2 changes: 2 additions & 0 deletions page.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
top: 0;
left: 0;
width: 100%;
max-width: 100%;
min-width: 100%;
height: 100%;

margin: 0;
Expand Down

0 comments on commit b2c7227

Please sign in to comment.