Skip to content

Commit

Permalink
v1.8.0 - 2021-01-20
Browse files Browse the repository at this point in the history
 * Changed the wording from `notification` to `content warning` since tumblr doesn't use notifications on the dashboard anymore
 * Fixed a bug where whitelisted posts would be hidden when content warnings are disabled
 * Restored the option to hide recommended posts (Fixes #66) (Fixes #64)
 * Found another source attribution block to hide
  • Loading branch information
bjornstar committed Jan 20, 2021
1 parent d69cf56 commit b890ae4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 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.8.0 - 2021-01-20
* Changed the wording from `notification` to `content warning` since tumblr doesn't use notifications on the dashboard anymore
* Fixed a bug where whitelisted posts would be hidden when content warnings are disabled
* Restored the option to hide recommended posts (Fixes #66) (Fixes #64)
* Found another source attribution block to hide

## v1.7.0 - 2020-12-28
* Make "Ignore filtered content" an option (Fixes #76)
* Add an option to hide filtered content
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.7.0",
"version": "1.8.0",
"description": "Would you like to control what shows up on your dashboard? Tumblr Savior is here to save you!",
"scripts": {
"test": "eslint src"
Expand Down
3 changes: 2 additions & 1 deletion src/data/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const defaultSettings = {
'hide_radar': true,
'hide_reblog_header': true,
'hide_recommended_blogs': true,
'hide_recommended_posts': true,
'hide_source': true,
'hide_sponsored': true,
'hide_sponsored_sidebar': true,
Expand All @@ -19,5 +20,5 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.7.0'
'version': '1.8.0'
}; // Initialize default values.
7 changes: 5 additions & 2 deletions src/data/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h2>White List</h2>
<div id="settingsDiv">
<h2>Tumblr Savior Behavior</h2>
<div id="show_notice_div">
<input type="checkbox" id="show_notice_cb" name="show_notice_cb" /> <label for="show_notice_cb">Show a notification when something has been hidden.</label>
<input type="checkbox" id="show_notice_cb" name="show_notice_cb" /> <label for="show_notice_cb">Show a content warning when something matches your blacklist.</label>
</div>
<div id="show_words_div">
<input type="checkbox" id="show_words_cb" name="show_words_cb" /> <label for="show_words_cb">Show which words have been hidden.</label>
Expand Down Expand Up @@ -74,11 +74,14 @@ <h2>Tumblr Behavior</h2>
<div id="hide_recommended_blogs_div">
<input type="checkbox" id="hide_recommended_blogs_cb" name="hide_recommended_blogs_cb" /> <label for="hide_recommended_blogs_cb">Hide recommended blogs in the sidebar.</label>
</div>
<div id="hide_recommended_posts_div">
<input type="checkbox" id="hide_recommended_posts_cb" name="hide_recommended_posts_cb" /> <label for="hide_recommended_posts_cb">Hide recommended posts.</label>
</div>
<div id="hide_sponsored_div">
<input type="checkbox" id="hide_sponsored_cb" name="hide_sponsored_cb" /> <label for="hide_sponsored_cb">Hide sponsored posts.</label>
</div>
<div id="hide_yahoo_ads_div">
<input type="checkbox" id="hide_sponsored_sidebar_cb" name="hide_sponsored_sidebar_cb" /> <label for="hide_sponsored_sidebar_cb">Hide the sponsored section in the sidebar</label>
<input type="checkbox" id="hide_sponsored_sidebar_cb" name="hide_sponsored_sidebar_cb" /> <label for="hide_sponsored_sidebar_cb">Hide the sponsored section in the sidebar.</label>
</div>
<div id="remove_redirects">
<input type="checkbox" id="remove_redirects_cb" name="remove_redirects_cb" /> <label for="remove_redirects_cb">Remove t.umblr.com redirects.</label>
Expand Down
1 change: 1 addition & 0 deletions src/data/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const settingsInputs = { //match up our settings object with our dom.
hide_radar: 'hide_radar_cb',
hide_reblog_header: 'hide_reblog_header_cb',
hide_recommended_blogs: 'hide_recommended_blogs_cb',
hide_recommended_posts: 'hide_recommended_posts_cb',
hide_source: 'hide_source_cb',
hide_sponsored: 'hide_sponsored_cb',
hide_sponsored_sidebar: 'hide_sponsored_sidebar_cb',
Expand Down
48 changes: 30 additions & 18 deletions src/data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const defaultSettings = {
'hide_radar': true,
'hide_reblog_header': true,
'hide_recommended_blogs': true,
'hide_recommended_posts': true,
'hide_source': true,
'hide_sponsored': true,
'hide_sponsored_sidebar': true,
Expand All @@ -18,11 +19,12 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.7.0'
'version': '1.8.0'
}; // Initialize default values.

const BASE_CONTAINER_ID = 'base-container';
const CSS_CLASS_MAP = {
attribution: '_2r26Q',
contentSource: 'hjr__',
controlIcon: '_33VXm',
controls: '_1kqDq',
Expand All @@ -35,6 +37,7 @@ const CSS_CLASS_MAP = {
noteCountButton: '_3t3fM',
reblog: '_3zgGl',
reblogHeader: '_2zTTs',
recommendationReason: '_nUEo',
stickyContainer: '_3wjj2',
tags: 'pOoZl',
textBlock: '_2m1qj'
Expand Down Expand Up @@ -66,7 +69,11 @@ const styleRules = {
hide_recommended_blogs: [
'aside > div:nth-child(1)' + howToHide
],
hide_recommended_posts: [
'.recommended-post' + howToHide
],
hide_source: [
css('attribution') + howToHide,
css('contentSource') + howToHide
],
hide_sponsored: [
Expand Down Expand Up @@ -275,7 +282,7 @@ function hide_tags() {
addGlobalStyle('show-tags', cssRules);
}

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

function extractText(node) {
// We were doing a naive tag removal and that worked until tumblr sometimes
Expand Down Expand Up @@ -470,18 +477,21 @@ function decoratePost(post, blackList) {
}
}

function undecoratePost(post) {
const existingNotices = post.getElementsByTagName('ts-notice');
function removeElement(element) {
element.parentNode.removeChild(element);
}

Array.prototype.forEach.call(existingNotices, existingNotice => {
existingNotice.parentNode.removeChild(existingNotice);
});
function removeByClassName(element, className) {
Array.prototype.forEach.call(element.getElementsByClassName(className), removeElement);
}

const existingButtons = post.getElementsByClassName('tumblr-savior-show');
function removeByTagName(element, tagName) {
Array.prototype.forEach.call(element.getElementsByTagName(tagName), removeElement);
}

Array.prototype.forEach.call(existingButtons, existingButton => {
existingButton.parentNode.removeChild(existingButton);
});
function undecoratePost(post) {
removeByTagName(post, 'ts-notice');
removeByClassName(post, 'tumblr-savior-show');
}

function checkPost(post) {
Expand Down Expand Up @@ -513,6 +523,8 @@ function checkPost(post) {
return out + innerHTML;
}, '');

const isRecommendedPost = postTags && postTags.querySelector(css('recommendationReason'));

if (postTags && !settings.ignore_tags) {
postText += extractText(postTags);
}
Expand All @@ -533,14 +545,14 @@ function checkPost(post) {
post.classList.add('has-filtered-content');
}

if (settings.show_notice) {
hydrationPromise.then(() => {
undecoratePost(post);
decoratePost(post, blackList, whiteList);
});
} else {
undecoratePost(post);
if (isRecommendedPost) {
post.classList.add('recommended-post');
}

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

function handleAnimationStart(event) {
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.7.0",
"version": "1.8.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 b890ae4

Please sign in to comment.