Skip to content

Commit

Permalink
v1.14.0 / 2023-01-23
Browse files Browse the repository at this point in the history
* [`main.js`] Continue using `chrome` instead of `browser` (Fixes #85)
* [`script.js`] Do not hide tags when a post is whitelisted (Fixes #86)
* [`script.js`] Refactor show/hide tags code
* [`script.js`] Skip blacklisting on drafts pages (Fixes #82)
  • Loading branch information
bjornstar committed Jan 23, 2023
1 parent 7a145fe commit d2a3130
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Tumblr Savior Changelog

## v1.14.0 / 2023-01-23
* [`main.js`] Continue using `chrome` instead of `browser` (Fixes #85)
* [`script.js`] Do not hide tags when a post is whitelisted (Fixes #86)
* [`script.js`] Refactor show/hide tags code
* [`script.js`] Skip blacklisting on drafts pages (Fixes #82)

## v1.13.0 / 2022-12-13
* [`script.js`] Use more specific selectors for hiding sidebar items (Fixes #83)
* [`options.js`] Replace deprecated `extension.getURL` with `runtime.getURL`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tumblr-savior",
"version": "1.13.0",
"version": "1.14.0",
"description": "Would you like to control what shows up on your dashboard? Tumblr Savior is here to save you!",
"scripts": {
"addons-linter": "addons-linter src",
Expand Down
2 changes: 1 addition & 1 deletion src/data/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.13.0'
'version': '1.14.0'
}; // Initialize default values.
28 changes: 8 additions & 20 deletions src/data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.13.0'
'version': '1.14.0'
}; // Initialize default values.

const BASE_CONTAINER_ID = 'base-container';
Expand Down Expand Up @@ -284,18 +284,6 @@ function addGlobalStyle(styleId, newRules) {
}
}

function show_tags() {
const cssRules = [ `.tumblr-savior-blacklisted ${css('tags')} {display:block!important;}` ];
addGlobalStyle('show-tags', cssRules);
}

function hide_tags() {
const cssRules = [ `.tumblr-savior-blacklisted ${css('tags')} {display:none!important;}` ];
addGlobalStyle('show-tags', cssRules);
}

const hideNoticesStyle = [ `article.tumblr-savior-blacklisted:not(.tumblr-savior-override) {display:none;}` ];

function extractText({ childNodes, nodeType, tagName, textContent }, isChildOfP) {
// We were doing a naive tag removal and that worked until tumblr sometimes
// didn't escape html in blog descriptions. So now we do it explicitly (#54)
Expand All @@ -310,14 +298,12 @@ function toggleStyle(id) {
addGlobalStyle(id, cssRules);
}

function applySettings() {
if (settings.show_tags) {
show_tags();
} else {
hide_tags();
}
const hideNoticesStyle = [ `article.tumblr-savior-blacklisted:not(.tumblr-savior-override) {display:none;}` ];
const hideTagsStyle = [ `.tumblr-savior-blacklisted:not(.tumblr-savior-override) ${css('tags')} {display:none!important;}` ];

function applySettings() {
addGlobalStyle('show-notices', settings.show_notice ? [] : hideNoticesStyle);
addGlobalStyle('show-tags', settings.show_tags ? [] : hideTagsStyle)

for (let id in styleRules) {
toggleStyle(id);
Expand Down Expand Up @@ -514,6 +500,8 @@ function checkPost(post) {
post.classList.remove('tumblr-savior-blacklisted');
post.removeAttribute('data-tumblr-savior-blacklist');

if (window.location.pathname.endsWith('/drafts')) return;

let postText = '';

const postHeader = post.querySelector('header');
Expand Down Expand Up @@ -564,7 +552,7 @@ function checkPost(post) {

hydrationPromise.then(() => {
undecoratePost(post);
decoratePost(post, blackList, whiteList);
decoratePost(post, blackList);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function chromeAddToBlackList(info, tab) {
}

const views = chrome.extension.getViews();
const optionsURI = browser.runtime.getURL('data/options.html');
const optionsURI = chrome.runtime.getURL('data/options.html');

Array.prototype.forEach.call(views, ({ location }) => {
if (location === optionsURI) location.reload();
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Tumblr Savior",
"version": "1.13.0",
"version": "1.14.0",
"description": "Would you like to control what shows up on your dashboard? Tumblr Savior is here to save you!",
"background": {
"scripts": [ "data/defaults.js", "lib/main.js" ]
Expand Down

0 comments on commit d2a3130

Please sign in to comment.