Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
msramalho committed Dec 5, 2023
1 parent 24368c1 commit 8630c23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 5 additions & 8 deletions source/js/timezone-fixers/bluesky.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Fixer from '../fixer.js';
import moment from 'moment-timezone';
import Fixer from '../fixer.js';
import {getLang} from '../utils.js';
/**
* This script enables uniform timestamps for bsky.app
* Timestamps handled by this script: ALL
Expand All @@ -10,15 +11,11 @@ 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 '),
filterSelected: note => note.dataset.tooltip?.includes('at '),
attachTo: node => node,
timestamp: node => moment(node.getAttribute('data-tooltip'), "MMM D, YYYY [at] h:mm A", getLang()).tz(moment.tz.guess()),
timestamp: node => moment(node.dataset.tooltip, 'MMM D, YYYY [at] h:mm A', getLang()).tz(moment.tz.guess()),
url: node => node?.href || window.location.href,
},
]);
function getLang() {
if (navigator.languages != undefined)
return navigator.languages[0];
return navigator.language;
}

fixer.start();
10 changes: 10 additions & 0 deletions source/js/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function getLang() {
if (navigator.languages !== undefined) {
return navigator.languages[0];
}

return navigator.language;
}

// Export all functions here defined
export {getLang};

0 comments on commit 8630c23

Please sign in to comment.