Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Release v1.2 (hotfix)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diéssica committed Aug 11, 2018
1 parent 82a9ee3 commit b05669a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 47 deletions.
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"tabWidth": 4,
"trailingComma": true,
"singleQuote": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For **manual installation**, download the [latest release](https://github.com/di


### Websites
> You can disable No Seen for a specific website by going to the extension preferences in your browser.
> You can disable No Seen for a specific website by going to the extension preferences in all browsers [except Chrome](https://github.com/diessica/no-seen/issues/2).
- Instagram (specifically Stories)
- Facebook (specifically Messenger)
Expand Down
49 changes: 31 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,45 @@
const INSTAGRAM_KEY = 'instagram'
const FACEBOOK_KEY = 'facebook'
const BLOCKED_URLS = [
'*://*.facebook.com/ajax/mercury/change_read_status.php*',
'*://*.instagram.com/stories/reel/seen',
const URLS_TO_CANCEL = [
'*://*.facebook.com/ajax/mercury/change_read_status.php*',
'*://*.instagram.com/stories/reel/seen',
]

const isNodeEnv = typeof exports !== 'undefined'

// Chrome support: `browser` should fallback to `chrome`
// since Chrome doesn't fully support WebExtensions
if (typeof browser === "undefined") {
browser = chrome;
if (typeof browser === 'undefined' && !isNodeEnv) {
browser = chrome
}

const shouldCancel = (url, storage) => {
const isAble = key => url.includes(key) && storage.get()
.then(s => s[key] !== false)
const shouldCancelRequest = (url, storage) => {
const isCancellable = key => {
if (chrome) {
// See: https://github.com/diessica/no-seen/issues/2
return true
}

return url.includes(key) && storage.get().then(s => s[key] !== false)
}

return isAble(FACEBOOK_KEY) || isAble(INSTAGRAM_KEY)
return {
cancel: [FACEBOOK_KEY, INSTAGRAM_KEY].some(isCancellable),
}
}

const onCancel = ({ originUrl: url }) =>
shouldCancel(url, browser.storage.sync)
.then(cancel => ({ cancel }))
const handleRequest = ({ url }) =>
shouldCancelRequest(url, browser.storage.sync)

const init = () => browser.webRequest.onBeforeRequest
.addListener(onCancel, { urls: BLOCKED_URLS }, ['blocking'])
const listenToRequests = () =>
browser.webRequest.onBeforeRequest.addListener(
handleRequest,
{ urls: URLS_TO_CANCEL },
['blocking']
)

if (typeof browser === 'undefined' && typeof exports !== 'undefined') {
exports.shouldCancel = shouldCancel
if (typeof browser === 'undefined' && isNodeEnv) {
exports.shouldCancelRequest = shouldCancelRequest
} else {
init()
}
listenToRequests()
}
52 changes: 26 additions & 26 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "No Seen",
"description": "Blocks \"seen\" marks on Facebook Messenger and Instagram Stories.",
"version": "1.1",
"manifest_version": 2,
"background": {
"scripts": ["index.js"]
},
"options_ui": {
"page": "preferences.html"
},
"permissions": [
"storage",
"webRequest",
"webRequestBlocking",
"*://*.facebook.com/*",
"*://*.instagram.com/*"
],
"developer": {
"name": "Diéssica Gurskas",
"url": "https://diessi.ca"
},
"applications": {
"gecko": {
"id": "no-seen@no.seen"
}
"name": "No Seen",
"description": "Blocks \"seen\" marks on Facebook Messenger and Instagram Stories.",
"version": "1.2",
"manifest_version": 2,
"background": {
"scripts": ["index.js"]
},
"options_ui": {
"page": "preferences.html"
},
"permissions": [
"storage",
"webRequest",
"webRequestBlocking",
"*://*.facebook.com/*",
"*://*.instagram.com/*"
],
"developer": {
"name": "Diéssica Gurskas",
"url": "https://diessi.ca"
},
"applications": {
"gecko": {
"id": "no-seen@no.seen"
}
}
}
}
11 changes: 9 additions & 2 deletions preferences.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang='en'>

<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
Expand All @@ -9,7 +10,7 @@
body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
font-family: -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif;
}

#main {
Expand All @@ -18,7 +19,7 @@
padding: 30px;
border-radius: 5px;
}

h1 {
margin-top: 0;
}
Expand All @@ -29,8 +30,13 @@
}
</style>
</head>

<body>
<main id='main'>
<p>⚠️ Does NOT work for Chrome at the moment. See <a href="https://github.com/diessica/no-seen/issues/2">issue on
GitHub.
</a></p>

<h1>Preferences</h1>
<h4>Enable for the following websites:</h4>

Expand All @@ -49,4 +55,5 @@ <h4>Enable for the following websites:</h4>

<script src='preferences.js'></script>
</body>

</html>

0 comments on commit b05669a

Please sign in to comment.