Skip to content

Commit

Permalink
v2.0.0 / 2024-11-12
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Nov 12, 2024
1 parent e3f4705 commit 8a1058d
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 289 deletions.
13 changes: 0 additions & 13 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [20.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Tumblr Savior Changelog

## v2.0.0 / 2024-11-12
* There is a one-time manual step you need to take in Tumblr Savior's options to read your localStorage settings and load it into browser extension storage.
Go to the Save / Load tab and press the "Read from localStorage" button then you can press the "Load" button to have it applied. It will save it to your
browser extension storage and work as normal from there on out.
* Switched to Manifest v3
* Tweaked sidebar blocking methodology
* [devDependencies] Updated `eslint` & `addons-linter` to latest versions
* [Workflows] Use node v22 for testing

## 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
Expand Down
16 changes: 16 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import js from "@eslint/js";
import globals from "globals";

export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.webextensions,
...globals.node,
}
},
}
]
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tumblr-savior",
"version": "1.16.0",
"version": "2.0.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,8 @@
},
"homepage": "https://github.com/bjornstar/Tumblr-Savior#readme",
"devDependencies": {
"addons-linter": "^6.24.0",
"eslint": "^8.57.0"
}
"addons-linter": "^7.3.0",
"eslint": "^9.14.0"
},
"type": "module"
}
26 changes: 0 additions & 26 deletions src/data/defaults.js

This file was deleted.

67 changes: 67 additions & 0 deletions src/data/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const defaultSettings = {
'context_menu': true,
'hide_filtered_content': false,
'hide_radar': true,
'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,
'ignore_tags': false,
'listBlack': ['trump'],
'listWhite': ['bjorn', 'octopus'],
'match_words': true,
'remove_redirects': true,
'show_notice': true,
'show_tags': true,
'show_words': true,
'version': '2.0.0'
}; // Initialize default values.

const { version } = defaultSettings;

function getSettings() {
return chrome.storage.local.get().then(settings => ({ ...defaultSettings, ...settings }));
}

function setupContextMenu() {
return getSettings().then(({ context_menu }) => {
return chrome.contextMenus.removeAll().then(() => {
if (context_menu === 'false' || !context_menu) return;

chrome.contextMenus.create({
contexts: ['selection'],
documentUrlPatterns: ['https://www.tumblr.com/*'],
id: 'addToBlackList',
title: 'Add \'%s\' to Tumblr Savior black list',
type: 'normal',
});
});
});
}

chrome.contextMenus.onClicked.addListener((info) => {
const theword = info.selectionText.trim();

if (!theword) return;

return getSettings().then(({ listBlack, ...settings }) => {
for (let v = 0; v < listBlack.length; v++) {
if (listBlack[v].toLowerCase() === theword.toLowerCase()) {
return alert('\'' + theword + '\' is already on your black list.');
}
}

listBlack.push(theword.toLowerCase());

return chrome.storage.local.set({ ...defaultSettings, ...settings, listBlack, version });
});
});

setupContextMenu();
14 changes: 14 additions & 0 deletions src/data/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,17 @@ div {
.ignore_label {
padding-right: 1em;
}

#v2_alert {
background-color:lightyellow;
border: solid 1px #4F545A;
border-radius: 3px;
display: none;
margin-bottom:1em;
padding: 1em;
width: 50%;
}

#v2_alert a {
text-decoration: underline;
}
21 changes: 14 additions & 7 deletions src/data/options.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<title>Options for Tumblr Savior</title>
<link rel="stylesheet" media="screen" href="../data/options.css">
<script src="../data/defaults.js" type="text/javascript"></script>
<script src="../data/options.js" type="text/javascript"></script>
<link rel="stylesheet" media="screen" href="options.css">
<script src="options.js" type="text/javascript"></script>
</head>
<body>
<div id="title">
Expand All @@ -17,6 +17,9 @@ <h1 style="line-height:32px;height:32px;margin-top:16px;">Tumblr Savior <span id
<div id="content">
<div id="foregroundDiv">
<div id="listsDiv">
<div id="v2_alert">
<p>It looks like you've updated to Tumblr Savior v2 and have some old settings, <a href="#saveload">go to the Save/Load tab</a> to restore them.</p>
</div>
<div id="listBlack">
<h2>Black List</h2>
<p>Tumblr Savior will save you from posts with these words in them:</p><br />
Expand Down Expand Up @@ -80,6 +83,7 @@ <h2>Tumblr Posts</h2>
<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>
<br />
<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>
Expand All @@ -88,16 +92,19 @@ <h2>Sidebar</h2>
<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>
<input type="checkbox" id="hide_sidebar_buttons_cb" name="hide_sidebar_buttons_cb" /> <label for="hide_sidebar_buttons_cb">Hide sidebar 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 />
<textarea id="inandout"></textarea><br /><br />
<p>Copy the above text into a file to save. You can load your saved settings by pasting it back into this box and hitting the Load button. Press the Restore defaults button if something goes horribly wrong.</p><br />
<textarea id="inandout"></textarea>
<button id="read_btn" style="margin-top:5px">Read from localStorage</button>
<br /><br />
<p>If you've recently updated to Tumblr Savior v2, you should be able to restore your old settings by pressing the "Read from localStorage" button and then hitting the Load button.</p><br />
<p>To save your settings, copy the above text into a file. You can load your saved settings by pasting it back into this box and hitting the Load button.</p><br />
</div>
<div id="aboutDiv">
<h2>About</h2><br />
Expand Down
Loading

0 comments on commit 8a1058d

Please sign in to comment.