Skip to content

Commit

Permalink
v1.16.0 / 2024-05-17
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Mar 17, 2024
1 parent d2edb90 commit e3f4705
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 42 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ jobs:
node-version: [20.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run build --if-present
- run: npm test
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Tumblr Savior Changelog

## v1.16.0 / 2024-05-17
* Updated hiding sponsored posts, now just does `moatContainer`
* Removed the hydration canary in favor of assuming hydration has succeeded the first time the base container is updated
* Apply default values when individual options have not been set yet
* Added a new option to block posts that are `timelineObject`s
* Added a new option to block buttons in the sidebar (Go ad-free today)
* Reorganized the options slightly to separate sidebar from posts
* Updates `eslint` & `addons-linter` to latest version
* Update more workflows to use node v20

## v1.15.0 / 2023-08-26
* Update for the latest version of the desktop
* New `CSS_CLASS_MAP` -- https://assets.tumblr.com/pop/cssmap-232fd5ad.json
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tumblr-savior",
"version": "1.15.0",
"version": "1.16.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 All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/bjornstar/Tumblr-Savior#readme",
"devDependencies": {
"addons-linter": "^6.12.0",
"eslint": "^8.48.0"
"addons-linter": "^6.24.0",
"eslint": "^8.57.0"
}
}
4 changes: 3 additions & 1 deletion src/data/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const defaultSettings = {
'hide_reblog_header': true,
'hide_recommended_blogs': true,
'hide_recommended_posts': true,
'hide_sidebar_buttons': true,
'hide_source': true,
'hide_sponsored': true,
'hide_sponsored_sidebar': true,
'hide_timeline_objects': true,
'ignore_body': false,
'ignore_filtered_content': true,
'ignore_header': false,
Expand All @@ -20,5 +22,5 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.15.0'
'version': '1.16.0'
}; // Initialize default values.
27 changes: 17 additions & 10 deletions src/data/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2>Tumblr Savior Behavior</h2>
<label for="ignore_tags_cb" class="ignore_label">Ignore tags</label>
</div>
<br />
<h2>Tumblr Behavior</h2>
<h2>Tumblr Posts</h2>
<div id="hide_source_div">
<input type="checkbox" id="hide_source_cb" name="hide_source_cb" /> <label for="hide_source_cb">Hide source attribution</label>
</div>
Expand All @@ -68,24 +68,31 @@ <h2>Tumblr Behavior</h2>
<div id="hide_filtered_content_div">
<input type="checkbox" id="hide_filtered_content_cb" name="hide_filtered_content_cb" /> <label for="hide_filtered_content_cb">Hide filtered content</label>
</div>
<div id="hide_radar_div">
<input type="checkbox" id="hide_radar_cb" name="hide_radar_cb" /> <label for="hide_radar_cb">Hide the radar in the sidebar</label>
</div>
<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>
<div id="hide_timeline_objects_div">
<input type="checkbox" id="hide_timeline_objects_cb" name="hide_timeline_objects_cb" /> <label for="hide_timeline_objects_cb">Hide timeline objects</label>
</div>
<div id="remove_redirects">
<div id="remove_redirects_div">
<input type="checkbox" id="remove_redirects_cb" name="remove_redirects_cb" /> <label for="remove_redirects_cb">Remove href.li redirects</label>
</div>
<h2>Sidebar</h2>
<div id="hide_radar_div">
<input type="checkbox" id="hide_radar_cb" name="hide_radar_cb" /> <label for="hide_radar_cb">Hide the radar</label>
</div>
<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</label>
</div>
<div id="hide_sidebar_buttons_div">
<input type="checkbox" id="hide_sidebar_buttons_cb" name="hide_sidebar_buttons_cb" /> <label for="hide_sidebar_buttons_cb">Hide buttons</label>
</div>
<div id="hide_sponsored_sidebar_div">
<input type="checkbox" id="hide_sponsored_sidebar_cb" name="hide_sponsored_sidebar_cb" /> <label for="hide_sponsored_sidebar_cb">Hide the sponsored section</label>
</div>
</div>
<div id="saveloadDiv">
<h2>Save / Load</h2><br />
Expand Down
4 changes: 3 additions & 1 deletion src/data/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const settingsInputs = { //match up our settings object with our dom.
hide_reblog_header: 'hide_reblog_header_cb',
hide_recommended_blogs: 'hide_recommended_blogs_cb',
hide_recommended_posts: 'hide_recommended_posts_cb',
hide_sidebar_buttons: 'hide_sidebar_buttons_cb',
hide_source: 'hide_source_cb',
hide_sponsored: 'hide_sponsored_cb',
hide_sponsored_sidebar: 'hide_sponsored_sidebar_cb',
hide_timeline_objects: 'hide_timeline_objects_cb',
ignore_body: 'ignore_body_cb',
ignore_filtered_content: 'ignore_filtered_content_cb',
ignore_header: 'ignore_header_cb',
Expand Down Expand Up @@ -96,7 +98,7 @@ function parseSettings() {
}
}

return parsedSettings;
return { ...defaultSettings, ...parsedSettings };
}

function removeElement(id) {
Expand Down
43 changes: 20 additions & 23 deletions src/data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const defaultSettings = {
'hide_reblog_header': true,
'hide_recommended_blogs': true,
'hide_recommended_posts': true,
'hide_sidebar_buttons': true,
'hide_source': true,
'hide_sponsored': true,
'hide_sponsored_sidebar': true,
'hide_timeline_objects': true,
'ignore_body': false,
'ignore_filtered_content': true,
'ignore_header': false,
Expand All @@ -19,13 +21,14 @@ const defaultSettings = {
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '1.15.0'
'version': '1.16.0'
}; // Initialize default values.

const BASE_CONTAINER_ID = 'base-container';
// index is 0 based
const CSS_CLASS_MAP = {
attribution: 'eqBap',
cell: 'rZlUD',
contentSource: 'd_FyU',
controlIcon: 'gc3fY',
controls: 'MCavR',
Expand Down Expand Up @@ -90,16 +93,22 @@ const styleRules = {
hide_recommended_posts: [
'.recommended-post' + howToHide
],
hide_sidebar_buttons: [
`aside > button${howToHide}`
],
hide_source: [
css('attribution') + howToHide,
css('contentSource') + howToHide
],
hide_sponsored: [
css('listTimelineObject') + ':not([data-id])' + howToHide
`${css('listTimelineObject')}.moatContainer ${howToHide}`,
],
hide_sponsored_sidebar: [
css('mrecContainer') + howToHide
]
],
hide_timeline_objects: [
`${css('cell')}[data-cell-id*="timelineObject"] ${howToHide}`,
],
};

const tumblrSaviorAnimation = [`
Expand Down Expand Up @@ -297,11 +306,6 @@ function extractText({ childNodes, nodeType, tagName, textContent }, isChildOfP)
return Array.prototype.filter.call(childNodes, ({ textContent }) => textContent).map(child => extractText(child, isChildOfP || tagName === 'P')).join('');
}

function toggleStyle(id) {
const cssRules = [...(settings[id] ? styleRules[id] : [])];
addGlobalStyle(id, cssRules);
}

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;}` ];

Expand All @@ -310,7 +314,8 @@ function applySettings() {
addGlobalStyle('show-tags', settings.show_tags ? [] : hideTagsStyle)

for (const id in styleRules) {
toggleStyle(id);
const cssRules = [...(settings[id] ? styleRules[id] : [])];
addGlobalStyle(id, cssRules);
}

gotSettings = true;
Expand Down Expand Up @@ -338,7 +343,7 @@ function parseSettings(savedSettings) {
let i, entry, test;

try {
settings = JSON.parse(savedSettings) || defaultSettings;
settings = { ...defaultSettings, ...JSON.parse(savedSettings) };
} catch (err) {
console.warn('Tumblr Savior: Error parsing settings, using defaults.');
settings = defaultSettings;
Expand Down Expand Up @@ -647,19 +652,11 @@ function waitForHydration(baseContainer) {
reject('Timed out waiting for hydration to complete');
}, 10000);

const hydrateCanary = document.createElement('hydrate-canary');

baseContainer.insertBefore(hydrateCanary, baseContainer.firstChild);

const observer = new MutationObserver(mutationList => {
for (let i = 0; i < mutationList.length; i += 1) {
if (Array.prototype.includes.call(mutationList[i].removedNodes, hydrateCanary)) {
observer.disconnect();
clearTimeout(hydrationTimeout);
baseContainer.classList.remove('hydrating');
return resolve();
}
}
const observer = new MutationObserver(() => {
observer.disconnect();
clearTimeout(hydrationTimeout);
baseContainer.classList.remove('hydrating');
resolve();
});

observer.observe(baseContainer, { childList: true });
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.15.0",
"version": "1.16.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 e3f4705

Please sign in to comment.