Permalink
Browse files

Initial commit.

  • Loading branch information...
Kadauchi committed May 24, 2018
1 parent 9db0599 commit 65564d90c27ea001cf7930b674965a4638c601f5
Showing with 94 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 .vscode/settings.json
  3. +10 −0 background/.eslintrc.json
  4. +9 −0 js/fetch-with-timeout.js
  5. +15 −0 js/mturk-date.js
  6. +19 −0 js/storage.js
  7. +14 −0 mturk/.eslintrc.json
  8. +1 −0 mturk/logged-in.js
  9. +23 −0 package.json
View
@@ -0,0 +1 @@
node_modules
View
@@ -0,0 +1,2 @@
{
}
View
@@ -0,0 +1,10 @@
{
"globals": {
"Fetch": false,
"StorageGetKey": false,
"mturkDate": false,
"HTML": false,
"ENCODE": false
}
}
View
@@ -0,0 +1,9 @@
// eslint-disable-next-line no-unused-vars
function Fetch(input, init, timeout) {
return Promise.race([
fetch(input, init),
new Promise((resolve, reject) =>
setTimeout(() => reject(new Error(`Fetch timeout.`)), timeout)
)
]);
}
View
@@ -0,0 +1,15 @@
// eslint-disable-next-line no-unused-vars
function MturkDate(offset = 0) {
const date = new Date(Date.now() - offset);
const toPST = date.toLocaleString(`en-US`, {
timeZone: `America/Los_Angeles`
});
const isPST = new Date(toPST);
const yyyy = isPST.getFullYear();
const mm = `0${isPST.getMonth()}`.slice(-2);
const dd = `0${isPST.getDate()}`.slice(-2);
return `${yyyy}${mm}${dd}`;
}
View
@@ -0,0 +1,19 @@
function StorageGet(keys) {
return new Promise(resolve => chrome.storage.local.get(keys, resolve));
}
async function StorageGetKey(key) {
const storage = await StorageGet(key);
return storage[key];
}
// eslint-disable-next-line no-unused-vars
function Enabled(name) {
return new Promise(async resolve => {
const options = await StorageGetKey(`options`);
if (options[name]) resolve();
else
window.console.warn(`"${name}" did not resolve because it is disabled.`);
});
}
View
@@ -0,0 +1,14 @@
{
"globals": {
"StorageGetKey": false,
"HTML": false,
"ReactDOM": false,
"ReactProps": false,
"Enabled": false,
"mturkDate": false
}
}
View
@@ -0,0 +1 @@
chrome.runtime.sendMessage({ loggedIn: true });
View
@@ -0,0 +1,23 @@
{
"name": "mturk-suite",
"version": "1.0.0",
"devDependencies": {
"eslint": "^4.9.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0"
},
"eslintConfig": {
"extends": ["airbnb-base", "prettier"],
"env": {
"browser": true,
"webextensions": true
},
"rules": {
"camelcase": 0,
"linebreak-style": 0
}
}
}

0 comments on commit 65564d9

Please sign in to comment.