Skip to content

Commit

Permalink
Merge pull request #14 from thanhvu1982/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
misa198 authored Jul 2, 2022
2 parents c71e6ef + 8b30dce commit d6d617c
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 45 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

==================

### v1.3.9

- Fix missing theme on commit diff page

### v1.3.8

- Fix missing theme after redirect

### v1.3.7

- Commit change view icons

### v1.3.6

- Add Icons to diff page
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "octotree-theme",
"description": "A Browser Extension which gives different filetypes different icons, and code color theme to GitHub and Octotree for free.",
"license": "BSD-2-Clause Simplified License",
"author": "Thanh Vu <misa198>",
"author": "Thanh Vu",
"homepage": "https://github.com/misa198/octotree-theme#readme",
"repository": {
"type": "git",
Expand All @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/misa198/octotree-theme/issues"
},
"version": "1.3.6",
"version": "1.3.9",
"scripts": {
"pre-commit": "lint-staged",
"build:firefox": "rm -rf build/firefox && cross-env PLATFORM=firefox webpack --config webpack.config.js",
Expand Down
2 changes: 0 additions & 2 deletions src/platforms/manifest.chromium-v2.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"manifest_version": 2,
"name": "Octotree Theme",
"author": "misa198",
"homepage_url": "https://github.com/misa198/octotree-theme",
"background": {
"scripts": ["background.js"]
},
Expand Down
2 changes: 0 additions & 2 deletions src/platforms/manifest.chromium.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"manifest_version": 3,
"name": "Octotree Theme",
"author": "misa198",
"homepage_url": "https://github.com/misa198/octotree-theme",
"background": {
"service_worker": "background.js"
},
Expand Down
2 changes: 0 additions & 2 deletions src/platforms/manifest.firefox.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"manifest_version": 2,
"name": "Octotree Theme",
"author": "misa198",
"homepage_url": "https://github.com/misa198/octotree-theme",
"background": {
"scripts": ["background.js"]
},
Expand Down
28 changes: 18 additions & 10 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
<link rel="stylesheet" href="popup.css" />
</head>
<body>
<a
href="https://github.com/misa198/octotree-theme"
rel="noreferrer"
target="__blank"
>
<header class="header">
<img class="header__icon" src="./icons/icon64.png" alt="" />
<h3 class="header__title">Octotree Theme</h3>
</header>
</a>
<header class="header">
<img class="header__icon" src="./icons/icon64.png" alt="" />
<h3 class="header__title">Octotree Theme</h3>
</header>
<main class="main">
<div class="session">
<h3 class="session__label">Code Theme</h3>
Expand Down Expand Up @@ -57,6 +51,20 @@ <h3 class="session_label">Octotree</h3>
</div>
</div>
</main>
<footer>
<p class="copyright">
<span id="OT_COPYRIGHT_VERSION"></span>
-
<span id="OT_COPYRIGHT_YEAR"></span>
©
<a
href="#"
rel="noreferrer"
target="__blank"
id="OT_COPYRIGHT_HOLDER"
></a>
</p>
</footer>
<script src="./popup.js"></script>
</body>
</html>
8 changes: 7 additions & 1 deletion src/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ chrome.tabs.onActivated.addListener(function (info) {
});
});

chrome.tabs.onUpdated.addListener(function (tabId, _, tab) {
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.status === 'complete') {
chrome.tabs.sendMessage(tabId, {
message: Keys.OT_TAB_UPDATE,
});
}

if (tab.url === undefined) {
return;
} else if (tab.url.match(urlRegex) === null) {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/constants/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export const Keys = {
OT_RELOAD: 'OT_RELOAD',
OT_CODE_COLOR_THEME: 'OT_CODE_COLOR_THEME',
OT_CODE_ICONS_THEME: 'OT_CODE_ICON_THEME',
OT_TAB_UPDATE: 'OT_TAB_UPDATE',
OT_COPYRIGHT_VERSION: 'OT_COPYRIGHT_VERSION',
OT_COPYRIGHT_YEAR: 'OT_COPYRIGHT_YEAR',
OT_COPYRIGHT_HOLDER: 'OT_COPYRIGHT_HOLDER',
};
55 changes: 29 additions & 26 deletions src/scripts/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,25 @@ const init = async () => {
}

if (githubDiff) {
observe(
'#files_bucket > diff-file-filter > diff-layout nav > ul li > .ActionList-content',
{
add(element) {
const filenameDom = select('.ActionList-item-label', element);
if (!filenameDom) return;
const dirIconDom = select(
'svg[aria-label=Directory]',
element
) as HTMLElement;
const fileIconDom = select(
'svg[aria-label=File]',
element
) as HTMLElement;
replaceGithubDiffIcon({
iconDom: dirIconDom || fileIconDom,
filenameDom,
isDir: Boolean(dirIconDom),
});
},
}
);
observe('diff-layout nav > ul li > .ActionList-content', {
add(element) {
const filenameDom = select('.ActionList-item-label', element);
if (!filenameDom) return;
const dirIconDom = select(
'svg[aria-label=Directory]',
element
) as HTMLElement;
const fileIconDom = select(
'svg[aria-label=File]',
element
) as HTMLElement;
replaceGithubDiffIcon({
iconDom: dirIconDom || fileIconDom,
filenameDom,
isDir: Boolean(dirIconDom),
});
},
});
}

if (octotree) {
Expand Down Expand Up @@ -315,13 +312,13 @@ const init = async () => {
// ============ Code color theme ===================

const changeTheme = (themeName?: string) => {
const body = document.querySelector('body') as HTMLElement;
const { classList } = body;
const html = document.querySelector('html') as HTMLElement;
const { classList } = html;
const currentThemeClass = Array.from(classList).find((className) =>
className.startsWith(`${colorThemeDeaultClass}`)
);
if (currentThemeClass) {
body.classList.remove(currentThemeClass);
html.classList.remove(currentThemeClass);
}
if (themeName) {
const foundTheme = colorThemes.find(
Expand All @@ -335,7 +332,7 @@ const changeTheme = (themeName?: string) => {
};

const applyColorTheme = async () => {
observe('body', {
observe('html', {
add() {
get([Keys.OT_CODE_COLOR_THEME], (result) => {
if (result) {
Expand Down Expand Up @@ -373,5 +370,11 @@ get(

init();
applyColorTheme();

chrome.runtime.onMessage.addListener(function (request) {
if (request.message === Keys.OT_TAB_UPDATE) {
applyColorTheme();
}
});
}
);
15 changes: 15 additions & 0 deletions src/scripts/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ import { colorThemes } from './constants/colorThemes';
import '../styles/popup.scss';
import { IconThemes } from './constants/iconThemes';

const manifestData = chrome.runtime.getManifest();
const copyrightVerison = document.getElementById(
Keys.OT_COPYRIGHT_VERSION
) as HTMLSpanElement;
const copyrightYear = document.getElementById(
Keys.OT_COPYRIGHT_YEAR
) as HTMLSpanElement;
const copyrightHolder = document.getElementById(
Keys.OT_COPYRIGHT_HOLDER
) as HTMLLinkElement;
copyrightVerison.innerText = `v${manifestData.version}`;
copyrightYear.innerText = new Date().getFullYear().toString();
copyrightHolder.href = manifestData.homepage_url as string;
copyrightHolder.innerText = manifestData.author as string;

const themeSelector = document.getElementById(
Keys.OT_CODE_COLOR_THEME
) as HTMLSelectElement;
Expand Down
10 changes: 10 additions & 0 deletions src/styles/popup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ body {
}
}
}

.copyright {
text-align: center;
font-size: 0.95em;
margin-bottom: 1rem;

#OT_COPYRIGHT_HOLDER {
text-decoration: underline !important;
}
}
}

@keyframes appear {
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const options = {
JSON.stringify({
description: process.env.npm_package_description,
version: process.env.npm_package_version,
author: process.env.npm_package_author_name,
homepage_url: process.env.npm_package_homepage,
...JSON.parse(content.toString()),
})
),
Expand Down

0 comments on commit d6d617c

Please sign in to comment.