Skip to content

Commit

Permalink
closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
msramalho committed Dec 5, 2023
1 parent 167d70e commit 24368c1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Install on [brave/chrome](https://chrome.google.com/webstore/detail/uniform-time

| Platform | Status | inspired by |
| --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Twitter || |
| Twitter/X || |
| Tiktok |* | [tiktok-timestamp](https://bellingcat.github.io/tiktok-timestamp/) |
| Discord |* | |
| Instagram || |
| Bluesky |* | works only for english translation of the platform, hard to expand |
| Linkedin | TODO | come help! [Linkedin-post-timestamp-extractor](https://ollie-boyd.github.io/Linkedin-post-timestamp-extractor/) |
| Youtube | TODO | come help! it requires the official API (see [amnesty youtube dataviewer](https://citizenevidence.amnestyusa.org/)) / and possibly file metadata |
| Facebook | TODO | come help! |
| GitHub | TODO | come help! |
| Bluesky | TODO | come help! |
| Vkontakte | TODO | is it possible? come help! |
| More | ... | please suggest more via [issues](https://github.com/bellingcat/uniform-timezone/issues) |

Expand Down
10 changes: 9 additions & 1 deletion source/js/fixer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import HoverPopup from './hover-popup.js';

/**
* @callback SelectedFilter
* @param {HTMLElement} node
* @returns {boolean}
*/

/**
* @callback URLResolver
* @param {HTMLElement} node
Expand All @@ -23,6 +29,7 @@ import HoverPopup from './hover-popup.js';
* @type {object}
* @property {string} name - Name of this target.
* @property {string} selector - DOM selector that resolves timestamp nodes.
* @property {SelectedFilter} filterSelected - Function that filters selected nodes (optional).
* @property {URLResolver} url - Function that resolves the canonical URL for a timestamp.
* @property {TimestampResolver} timestamp - Function that resolves the ISO timestamp for a node.
* @property {AttachToResolver} attachTo - Function that resolves where the popup should attach to.
Expand Down Expand Up @@ -63,7 +70,8 @@ class Fixer {
}

getNodes(target) {
const nodes = Array.from(document.querySelectorAll(target.selector));
const nodes = Array.from(document.querySelectorAll(target.selector))
.filter(node => target.filterSelected === undefined || target.filterSelected(node));
return nodes.filter(node => !this.processed.has(node));
}
}
Expand Down
24 changes: 24 additions & 0 deletions source/js/timezone-fixers/bluesky.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Fixer from '../fixer.js';
import moment from 'moment-timezone';

Check failure on line 2 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

`moment-timezone` import should occur before import of `../fixer.js`
/**
* This script enables uniform timestamps for bsky.app
* Timestamps handled by this script: ALL
* How: by detecting a/div elements with data-tooltip and appending a hover popup to them.
* NOTE: only working for English translations of the platform.
*/
const fixer = new Fixer('Bluesky', [
{
name: 'Tweet Timestamps',
selector: 'a[data-tooltip][aria-label],div[data-tooltip]',
filterSelected: note => note.getAttribute('data-tooltip')?.includes('at '),

Check failure on line 13 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Prefer `.dataset` over `getAttribute(…)`.
attachTo: node => node,
timestamp: node => moment(node.getAttribute('data-tooltip'), "MMM D, YYYY [at] h:mm A", getLang()).tz(moment.tz.guess()),

Check failure on line 15 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Prefer `.dataset` over `getAttribute(…)`.

Check failure on line 15 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Strings must use singlequote.
url: node => node?.href || window.location.href,
},
]);
function getLang() {
if (navigator.languages != undefined)

Check failure on line 20 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Expected '!==' and instead saw '!='.
return navigator.languages[0];

Check failure on line 21 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Mixed spaces and tabs.

Check failure on line 21 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Expected { after 'if' condition.
return navigator.language;
}

Check failure on line 23 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Expected indentation of 0 tabs but found 2 spaces.
fixer.start();

Check failure on line 24 in source/js/timezone-fixers/bluesky.js

View workflow job for this annotation

GitHub Actions / test

Expected blank line before this statement.
11 changes: 8 additions & 3 deletions source/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Uniform Timezone Extension",
"version": "0.0.9",
"version": "0.0.10",
"description": "Brings standardization to social media posts' dates and times.",
"homepage_url": "https://github.com/bellingcat/uniform-timezone",
"manifest_version": 3,
Expand Down Expand Up @@ -33,11 +33,16 @@
"js": ["js/timezone-fixers/discord.js"],
"css": ["css/hover-popup.css"],
"run_at": "document_end"
},{
}, {
"matches": ["https://*.instagram.com/*"],
"js": ["js/timezone-fixers/instagram.js"],
"css": ["css/hover-popup.css"],
"run_at": "document_end"
}, {
"matches": ["https://bsky.app/*"],
"js": ["js/timezone-fixers/bluesky.js"],
"css": ["css/hover-popup.css"],
"run_at": "document_end"
}],
"action": {
"default_popup": "html/popup.html"
Expand All @@ -48,7 +53,7 @@
},
"web_accessible_resources": [{
"resources": ["img/icon-128.png"],
"matches": ["https://twitter.com/*", "https://*.tiktok.com/*", "https://web.archive.org/*", "https://discord.com/*", "https://*.instagram.com/*"]
"matches": ["https://twitter.com/*", "https://*.tiktok.com/*", "https://x.com/*", "https://*.x.com/*", "https://web.archive.org/*", "https://discord.com/*", "https://*.instagram.com/*", "https://bsky.app/*"]
}],
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh1mCI9IkJLVJNEYZxa/OzIS13t3UGLlXwTyISY8i0Ouy8y1NG2k0qJSX9rtbZq6DKxl+JsHyvSzOVxb8SDj4FYmdOk0URqDGzTZYJqGuWUsJ4WQJ/mHsBa/33Xvvmp+qAc5MXWzt7lGK4s9RRSy61WDxmEdKb0aqZM2zvnmOv0E7V8KpUEMVrwyrfSbiZjz6EGusrSqIhQDVijt/VQS9zUJ1jLRNcoa5PcIYPRHAr3N0IXvZeLP1Q6rtd81FXZqocHYb+HP8v5bUyfXKpuVWxNI8Bpd66dr4bdGFueVJcUg0QuR06TKfon8NWHh+iKEH6SzDmAD2yJTtqHweheZU4QIDAQAB"
}

0 comments on commit 24368c1

Please sign in to comment.