Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ overlapping pair of patterns A -> B and B -> C, then A - > C is shown.
[Chrome](https://chrome.google.com/webstore/detail/abmchgifbehnkekmmfmkkgdbhcphmeoi)

## Latest changes
- Add new icons (by Spade1345)
## Last change
- Add preference to make a list of domains exempt from text replacement (https://github.com/pelmers/text-rewriter/issues/6)
- Add preference to skip children of `<pre>` and `<code>` tags from replacement
Binary file added data/icon2_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icon2_fav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions data/prefs.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* {
font-family: Rubik, sans-serif
}
#scratchpad {
width: 60%;
height: 200px;
Expand Down
16 changes: 8 additions & 8 deletions data/prefs.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<link rel="stylesheet" type="text/css" href="prefs.css">
</head>
<body>
<h1>Text Rewriter Settings</h1>
<div class="experimental_group">
<div>
<input type="checkbox" value=false id="use_dynamic_checkbox" />
(EXPERIMENTAL) Replace text dynamically on page changes
</div>
<div id="dynamic_timeout_group">
<input type="number" value=2000 id="dynamic_timeout" min=1 />
Dynamic update interval lower bound (milliseconds)
</div>
<abbr title="">Dynamic update interval lower bound (milliseconds)</abbr>
<div>
<input type="checkbox" value=false id="skip_pre_tags" />
Do not replace preformatted text (&lt;pre&gt; tags)
Expand All @@ -24,7 +24,7 @@
</div>
<p>
Smart case tries to match case on replace to/from:
e.g. the rule cloud -> butt will also add rules for
e.g. the rule cloud -> butt will add rules for
Cloud -> Butt and CLOUD -> BUTT.
</p>
<table id="pref_table">
Expand All @@ -37,13 +37,13 @@
</tr>
</table>
<div class="button_group">
<button id="add_button" type="button">Add Rule</button>
<button id="save_button" type="button">Save</button>
<button id="import_button" type="button">Import</button>
<button id="clear_button" type="button">Clear All</button>
<abbr title="Add a new rule."><button id="add_button" type="button">Add Rule</button></abbr>
<abbr title="Save added rules"><button id="save_button" type="button">Save</button></abbr>
<abbr title="Import rules"><button id="import_button" type="button">Import</button></abbr>
<abbr title="Clear all rules in the list"><button id="clear_button" type="button">Clear All</button></abbr>
<div id="saved_text" style="display:none;">Saved</div>
</div>
<h3>Disabled Sites
<h2>Disabled Sites</h2>
<table id="website_table">
<tr id="website_header">
<th>Pattern
Expand Down
6 changes: 3 additions & 3 deletions data/text-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const api = chrome;

const NODE_LIMIT = 50000;

// this is some text => This Is Some Text
// this is some text => This Is Some Text | proper case handling
function titleCase(str) {
const parts = str.split(' ');
for (let i = 0; i < parts.length; i++) {
Expand All @@ -13,7 +13,7 @@ function titleCase(str) {
return parts.join(' ');
}

// this is some text => This is some text
// this is some text => This is some text | sentence case handling
function sentenceCase(str) {
const parts = str.split(' ');
for (let i = 0; i < parts.length; i++) {
Expand All @@ -26,7 +26,7 @@ function sentenceCase(str) {
return parts.join(' ');
}

// delete duplicate copies of replacements entries.
// Delete duplicate replacement entries
function dedup(replacements) {
const deduped = [];
for (let i = 0; i < replacements.length; i++) {
Expand Down
8 changes: 6 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const DEFAULT_DYNAMIC_REPLACE_INTERVAL_MS = 2000;

const DISABLED_MSG = "⛔️";

// Override DISABLED_MSG badge text (uncomment to use)
//const DISABLED_MSG = "↻";

Comment thread
spade1345 marked this conversation as resolved.

// Send replacement lists to the given tab id.
function updateTab(id) {
storage.get({
Expand Down Expand Up @@ -67,7 +71,7 @@ api.browserAction.onClicked.addListener(function (tab) {
if (!isBlocked(data.blockPatterns, tab.url)) {
data.blockPatterns.push({pattern: makePattern(tab.url)})
storage.set({blockPatterns: data.blockPatterns}, () => {
api.browserAction.setBadgeText({text: "🔄", tabId: tab.id});
api.browserAction.setBadgeText({text: "", tabId: tab.id});
api.browserAction.setBadgeBackgroundColor({color: [102,102,102,255]});
});
} else {
Expand All @@ -77,7 +81,7 @@ api.browserAction.onClicked.addListener(function (tab) {
updateTab(tab.id);
} else {
// in this case it's already disabled, but it was bypassed (ask user to reload)
api.browserAction.setBadgeText({text: "🔄", tabId: tab.id});
api.browserAction.setBadgeText({text: "", tabId: tab.id});
api.browserAction.setBadgeBackgroundColor({color: [102,102,102,255]});
}
});
Expand Down
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"page": "data/prefs.html"
},
"browser_action": {
"default_icon": "data/icon.png"
"default_icon": "data/icon2_fav.png"
},
"content_scripts": [
{
Expand All @@ -34,7 +34,7 @@
"persistent": false
},
"icons": {
"48": "data/icon.png",
"64": "data/icon64.png"
"48": "data/icon2_fav.png",
"64": "data/icon2_64.png"
}
}