Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c63eca

Browse files
committed
remove hide/show rating button from settings
1 parent 56f2fe6 commit 4c63eca

File tree

4 files changed

+30
-62
lines changed

4 files changed

+30
-62
lines changed

‎src/background/background.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ chrome.runtime.onInstalled.addListener(() => {
4040
});
4141

4242
// Load default settings
43-
chrome.storage.local.set({ fontSize: 12 });// Default to small display size
43+
chrome.storage.local.set({ fontSize: 14 });
4444
chrome.storage.local.set({ showExamples: true });
4545
chrome.storage.local.set({ showDifficulty: true });
46-
chrome.storage.local.set({ showRating: true });
4746
chrome.storage.local.set({ showCompanyTags: true });
4847
// Set default theme to auto mode and default to dark
4948
chrome.storage.local.set({ isDarkTheme: true }); // Default to dark theme

‎src/content-script/update-description-tab.ts

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -105,57 +105,46 @@ function showDifficulty() {
105105
});
106106
}
107107

108-
// show the leetcode problem rating if the user has enabled it in the settings
108+
// show the leetcode problem rating
109109
function showRating(problemTitle: string) {
110110
// Check if we're on the description tab before proceeding
111111
const isDescriptionPage = !window.location.href.includes('/solutions');
112112
if (!isDescriptionPage) {
113113
return;
114114
}
115115

116-
chrome.storage.local.get(['showRating'], (result) => {
117-
const showRating = result.showRating;
118-
if (!showRating) {
119-
const ratingElement = document.getElementById('rating');
120-
if (ratingElement) {
121-
ratingElement.remove();
122-
}
123-
return;
124-
}
125-
126-
chrome.storage.local.get(['leetcodeProblems'], (result) => {
127-
const problem = result.leetcodeProblems.questions.find((problem: Problem) => problem.title === problemTitle);
128-
if (!problem?.rating) return;
129-
130-
let ratingElement = document.getElementById('rating');
131-
if (!ratingElement) {
132-
ratingElement = document.createElement('div');
133-
ratingElement.id = 'rating';
134-
}
135-
136-
ratingElement.textContent = problem.rating;
137-
ratingElement.style.fontSize = '11px';
138-
ratingElement.style.letterSpacing = '.5px';
139-
ratingElement.style.borderRadius = '6px';
140-
ratingElement.style.width = '60px';
141-
ratingElement.style.textAlign = 'center';
142-
ratingElement.style.padding = '4px 8px';
143-
ratingElement.style.transition = 'all 0.2s ease';
116+
chrome.storage.local.get(['leetcodeProblems'], (result) => {
117+
const problem = result.leetcodeProblems.questions.find((problem: Problem) => problem.title === problemTitle);
118+
if (!problem?.rating) return;
144119

145-
chrome.storage.local.get(['isDarkTheme'], (result) => {
146-
const isDark = result.isDarkTheme;
147-
if (ratingElement) {
148-
ratingElement.style.backgroundColor = isDark ? '#373737' : '#f3f4f5';
149-
ratingElement.style.color = isDark ? '#40a9ff' : '#1a1a1a';
150-
ratingElement.style.border = `1px solid ${isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'}`;
151-
}
152-
});
120+
let ratingElement = document.getElementById('rating');
121+
if (!ratingElement) {
122+
ratingElement = document.createElement('div');
123+
ratingElement.id = 'rating';
124+
}
153125

154-
const difficultyContainer = document.querySelectorAll('div.relative.inline-flex')[0] as HTMLDivElement;
155-
if (difficultyContainer?.parentElement && ratingElement) {
156-
difficultyContainer.parentElement.insertBefore(ratingElement, difficultyContainer.parentElement.firstChild);
126+
ratingElement.textContent = problem.rating;
127+
ratingElement.style.fontSize = '11px';
128+
ratingElement.style.letterSpacing = '.5px';
129+
ratingElement.style.borderRadius = '6px';
130+
ratingElement.style.width = '60px';
131+
ratingElement.style.textAlign = 'center';
132+
ratingElement.style.padding = '4px 8px';
133+
ratingElement.style.transition = 'all 0.2s ease';
134+
135+
chrome.storage.local.get(['isDarkTheme'], (result) => {
136+
const isDark = result.isDarkTheme;
137+
if (ratingElement) {
138+
ratingElement.style.backgroundColor = isDark ? '#373737' : '#f3f4f5';
139+
ratingElement.style.color = isDark ? '#40a9ff' : '#1a1a1a';
140+
ratingElement.style.border = `1px solid ${isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'}`;
157141
}
158142
});
143+
144+
const difficultyContainer = document.querySelectorAll('div.relative.inline-flex')[0] as HTMLDivElement;
145+
if (difficultyContainer?.parentElement && ratingElement) {
146+
difficultyContainer.parentElement.insertBefore(ratingElement, difficultyContainer.parentElement.firstChild);
147+
}
159148
});
160149
}
161150

‎src/popup/settings.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
<button id="show-difficulty-btn" class="material-button settings-btn">
4848
<span id="show-difficulty-icon"></span> Show Difficulty
4949
</button>
50-
<button id="show-rating-btn" class="material-button settings-btn">
51-
<span id="show-rating-icon"></span> Show Rating
52-
</button>
5350
<div id="review">
5451
Leave us a
5552
<a target="_blank"

‎src/popup/settings.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ document.addEventListener('DOMContentLoaded', () => {
109109
const showDifficultyIcon = document.getElementById('show-difficulty-icon');
110110
if (showDifficultyIcon) showDifficultyIcon.textContent = result.showDifficulty ? '✅' : '❌';
111111
});
112-
113-
chrome.storage.local.get(['showRating'], (result) => {
114-
const showRatingIcon = document.getElementById('show-rating-icon');
115-
if (showRatingIcon) showRatingIcon.textContent = result.showRating ? '✅' : '❌';
116-
});
117112

118113
// Helper function to send messages safely to content script
119114
function safelySendMessage(message: any) {
@@ -190,16 +185,4 @@ document.addEventListener('DOMContentLoaded', () => {
190185
});
191186
});
192187
});
193-
194-
const showRatingBtn = document.getElementById('show-rating-btn');
195-
showRatingBtn && showRatingBtn.addEventListener('click', function () {
196-
chrome.storage.local.get(['showRating'], (result) => {
197-
const showRating = !result.showRating;
198-
chrome.storage.local.set({ showRating: showRating }, () => {
199-
const showRatingIcon = document.getElementById('show-rating-icon');
200-
if (showRatingIcon) showRatingIcon.textContent = showRating ? '✅' : '❌';
201-
safelySendMessage({ action: 'updateDescription', title: document.title || 'title' });
202-
});
203-
});
204-
});
205188
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /