Skip to content

Commit 7a0773f

Browse files
style: format code style
1 parent 16fa313 commit 7a0773f

15 files changed

Lines changed: 3725 additions & 3524 deletions

.github/dependabot.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
version: 2
22
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
labels:
9+
- "dependencies"
310

4-
# Maintain dependencies for GitHub Actions
5-
- package-ecosystem: "github-actions"
6-
directory: "/"
7-
schedule:
8-
interval: "daily"
9-
labels:
10-
- "dependencies"
11-
12-
# Maintain dependencies for yarn
13-
- package-ecosystem: "npm"
14-
directory: "/"
15-
schedule:
16-
interval: "daily"
17-
labels:
18-
- "dependencies"
11+
# Maintain dependencies for yarn
12+
- package-ecosystem: "npm"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
labels:
17+
- "dependencies"

.github/workflows/themeList.yml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
11
name: Update monkeytype theme json list
22

33
on:
4-
schedule:
5-
- cron: '0 */24 * * *'
6-
workflow_dispatch:
4+
schedule:
5+
- cron: "0 */24 * * *"
6+
workflow_dispatch:
77

88
jobs:
9-
make-request:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v4
14-
15-
- name: Set up Node.js
16-
uses: actions/setup-node@v3
17-
with:
18-
node-version: '16.x'
19-
20-
- name: Download theme json file from monkeytype
21-
run: wget --timeout=180 --tries=3 --waitretry=10 --output-document=theme/themes.json https://monkeytype-readme.zeabur.app/mr-command/theme
22-
timeout-minutes: 10
23-
24-
- name: Format JSON data
25-
run: |
26-
python3 -c 'import json; data = json.load(open("theme/themes.json")); json.dump(data, open("theme/themes.json", "w"), indent=2)'
27-
28-
- name: Print json file contents
29-
run: cat theme/themes.json
30-
31-
- name: Update theme list
32-
uses: actions/github-script@v6
33-
with:
34-
script: |
35-
const fs = require('fs');
36-
let monkeytypeThemesJson = fs.readFileSync('theme/themes.json');
37-
const filePath = '${{ github.workspace }}/theme/themes.json';
38-
fs.writeFileSync(filePath, monkeytypeThemesJson);
39-
40-
- name: Print updated theme contents
41-
run: |
42-
cat theme/themes.json
43-
44-
- name: Configure git
45-
run: |
46-
git config --global user.name "ridemountainpig"
47-
git config --global user.email "lin0905580802@gmail.com"
48-
49-
- name: Commit and push changes
50-
run: |
51-
if git diff-index --quiet HEAD --; then
52-
echo "No changes detected."
53-
else
54-
git add .
55-
git commit -m "feat: update themes json list"
56-
fi
57-
continue-on-error: true
58-
59-
- name: Push changes
60-
uses: ad-m/github-push-action@master
61-
with:
62-
branch: master
63-
github_token: ${{ secrets.GITHUB_TOKEN }}
9+
make-request:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: "16.x"
19+
20+
- name: Download theme json file from monkeytype
21+
run: wget --timeout=180 --tries=3 --waitretry=10 --output-document=theme/themes.json https://monkeytype-readme.zeabur.app/mr-command/theme
22+
timeout-minutes: 10
23+
24+
- name: Format JSON data
25+
run: |
26+
python3 -c 'import json; data = json.load(open("theme/themes.json")); json.dump(data, open("theme/themes.json", "w"), indent=2)'
27+
28+
- name: Print json file contents
29+
run: cat theme/themes.json
30+
31+
- name: Update theme list
32+
uses: actions/github-script@v6
33+
with:
34+
script: |
35+
const fs = require('fs');
36+
let monkeytypeThemesJson = fs.readFileSync('theme/themes.json');
37+
const filePath = '${{ github.workspace }}/theme/themes.json';
38+
fs.writeFileSync(filePath, monkeytypeThemesJson);
39+
40+
- name: Print updated theme contents
41+
run: |
42+
cat theme/themes.json
43+
44+
- name: Configure git
45+
run: |
46+
git config --global user.name "ridemountainpig"
47+
git config --global user.email "lin0905580802@gmail.com"
48+
49+
- name: Commit and push changes
50+
run: |
51+
if git diff-index --quiet HEAD --; then
52+
echo "No changes detected."
53+
else
54+
git add .
55+
git commit -m "feat: update themes json list"
56+
fi
57+
continue-on-error: true
58+
59+
- name: Push changes
60+
uses: ad-m/github-push-action@master
61+
with:
62+
branch: master
63+
github_token: ${{ secrets.GITHUB_TOKEN }}

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
monkeytype-icons

.prettierrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"tabWidth": 4
3+
}

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ You just need to click Turn On and click blank key on keyboard it will help you
2424
<img width="351" alt="CleanShot 2023-04-03 at 13 07 18@2x" src="https://github.com/ridemountainpig/monkeytype-chrome-extension/assets/92412722/bd8003c4-af54-4c6f-bf12-c4483388f66c">
2525

2626
## Other
27-
- Extension Icon: Icon made by MonkeyType from [MonkeyType favicon](https://raw.githubusercontent.com/monkeytypegame/monkeytype/master/frontend/static/images/favicon/favicon.ico)
28-
- Extension Theme: Theme style from [MonkeyType theme list](https://github.com/monkeytypegame/monkeytype/blob/master/frontend/static/themes/_list.json)
27+
28+
- Extension Icon: Icon made by MonkeyType from [MonkeyType favicon](https://raw.githubusercontent.com/monkeytypegame/monkeytype/master/frontend/static/images/favicon/favicon.ico)
29+
- Extension Theme: Theme style from [MonkeyType theme list](https://github.com/monkeytypegame/monkeytype/blob/master/frontend/static/themes/_list.json)

background.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
const init = (tab) => {
22
const { id, url } = tab;
3-
chrome.scripting.executeScript(
4-
{
5-
target: { tabId: id, allFrames: true },
6-
files: ['monkeyType.js']
7-
}
8-
)
3+
chrome.scripting.executeScript({
4+
target: { tabId: id, allFrames: true },
5+
files: ["monkeyType.js"],
6+
});
97
console.log(`monkey type extension turn on`);
10-
}
8+
};
119

1210
// chrome.action.onClicked.addListener(tab => {
1311
// init(tab)
1412
// });
1513

1614
// Add a listener for messages from the popup
1715
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
18-
if (message === 'init') {
16+
if (message === "init") {
1917
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
2018
let [tab] = tabs;
2119
init(tab);
2220
});
2321
}
24-
if (message.type === 'storeData') {
22+
if (message.type === "storeData") {
2523
const data = message.data;
2624
storeData(data);
2725
}
28-
if (message.type === 'getData') {
29-
getData(message.data, function(result) {
26+
if (message.type === "getData") {
27+
getData(message.data, function (result) {
3028
sendResponse(result);
3129
});
3230
return true; // This is necessary to indicate that we will be sending a response asynchronously
3331
}
34-
if (message.type === 'changeIcon') {
32+
if (message.type === "changeIcon") {
3533
changeIcon(message.data.themeName);
3634
}
3735
});
3836

3937
const storeData = (data) => {
4038
chrome.storage.local.set(data, function () {
41-
console.log(data)
39+
console.log(data);
4240
if (chrome.runtime.lastError) {
4341
console.error(chrome.runtime.lastError);
4442
} else {
45-
console.log('Data saved:', data);
43+
console.log("Data saved:", data);
4644
}
4745
});
4846
};
@@ -52,7 +50,7 @@ const getData = (key, callback) => {
5250
if (chrome.runtime.lastError) {
5351
console.error(chrome.runtime.lastError);
5452
} else {
55-
console.log('Data retrieved:', result[key]);
53+
console.log("Data retrieved:", result[key]);
5654
callback(result[key]);
5755

5856
const iconPath = `./monkeytype-icons/${result[key]}.png`;
@@ -64,4 +62,4 @@ const getData = (key, callback) => {
6462
const changeIcon = (themeName) => {
6563
const iconPath = `./monkeytype-icons/${themeName}.png`;
6664
chrome.action.setIcon({ path: iconPath });
67-
}
65+
};

input.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@tailwind base;
22
@tailwind components;
3-
@tailwind utilities;
3+
@tailwind utilities;

manifest.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,5 @@
1919
"background": {
2020
"service_worker": "background.js"
2121
},
22-
"permissions": [
23-
"activeTab",
24-
"scripting",
25-
"storage"
26-
]
22+
"permissions": ["activeTab", "scripting", "storage"]
2723
}

monkeyType.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const wordsInput = document.getElementById('wordsInput');
1+
const wordsInput = document.getElementById("wordsInput");
22

3-
wordsInput.addEventListener('keypress', function (event) {
3+
wordsInput.addEventListener("keypress", function (event) {
44
if (event.which === 32) {
5-
let wordElement = document.querySelector('.word.active');
6-
let letters = wordElement.querySelectorAll('letter');
7-
let word = '';
5+
let wordElement = document.querySelector(".word.active");
6+
let letters = wordElement.querySelectorAll("letter");
7+
let word = "";
88

99
letters.forEach(function (letter) {
1010
word += letter.textContent;
1111
});
1212
console.log(word);
1313
wordsInput.value = " " + word;
1414
}
15-
});
15+
});

0 commit comments

Comments
 (0)