Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Test
on:
pull_request:
push:
workflow_dispatch:
schedule:
- cron: "0 8 * * *" # Every day at 8:00 UTC https://crontab.guru/#0_8_*_*_*

Expand Down
16 changes: 4 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,19 @@
},
"jest": {
"preset": "jest-puppeteer",
"globals": {
"ts-jest": {
"tsconfig": "tests/tsconfig.tests.json"
}
},
"transform": {
".(ts|tsx)": "ts-jest"
"^.+(\\.(ts|tsx)|select-dom/.+\\.js)$": "ts-jest"
},
"transformIgnorePatterns": ["/node_modules/(?!select-dom)"],
"testRegex": "(/tests/.*\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/tests/"
],
"collectCoverageFrom": [
"packages/**/*.{js,ts,tsx}"
]
"moduleFileExtensions": ["ts", "tsx", "js"],
"coveragePathIgnorePatterns": ["/node_modules/", "/tests/"],
"collectCoverageFrom": ["packages/**/*.{js,ts,tsx}"]
},
"repository": {
"type": "git",
Expand Down
16 changes: 8 additions & 8 deletions packages/ManifestChrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@ const manifest = {
icons: {
'128': 'icon128.png',
'48': 'icon48.png',
'16': 'icon16.png'
'16': 'icon16.png',
},
version: '1.23',
author: 'Daniel Derevjanik <daniel.derevjanik@gmail.com>',
offline_enabled: true,
browser_action: {
default_icon: {
'128': 'icon128.png',
'48': 'icon48.png'
}
'48': 'icon48.png',
},
},
background: {
scripts: ['background.js'],
persistent: false
persistent: false,
},
web_accessible_resources: ['icons/*.svg', 'images/*.gif'],
content_scripts: [
{
css: ['content.css'],
matches: ['*://*/*'],
js: ['content.js'],
run_at: 'document_idle'
}
run_at: 'document_idle',
},
],
permissions: [
'storage',
Expand All @@ -40,8 +40,8 @@ const manifest = {
'*://gist.github.com/*',
'*://gitlab.com/*',
'*://pastebin.com/*',
'*://sourceforge.net/*'
]
'*://sourceforge.net/*',
],
};

export const createChromeManifest = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ManifestEdge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const createEdgeManifest = () => {
// @ts-ignore
manifest['-ms-preload'] = {
backgroundScript: 'backgroundScriptsAPIBridge.js',
contentScript: 'contentScriptsAPIBridge.js'
contentScript: 'contentScriptsAPIBridge.js',
};
return manifest;
};
14 changes: 7 additions & 7 deletions packages/common/HostData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ const hostData: { [H in SupportedHostings]: HostData } = {
bitbucket: {
fullName: 'Bitbucket',
favicon: 'bitbucket-favicon.ico',
host: 'bitbucket'
host: 'bitbucket',
},
github: {
fullName: 'Github',
favicon: 'github-favicon.ico',
host: 'github'
host: 'github',
},
githubgist: {
fullName: 'Github Gist',
favicon: 'github-favicon.ico',
host: 'gist.github'
host: 'gist.github',
},
gitlab: {
fullName: 'Gitlab',
favicon: 'gitlab-favicon.ico',
host: 'gitlab'
host: 'gitlab',
},
pastebin: {
fullName: 'Pastebin',
favicon: 'pastebin-favicon.ico',
host: 'pastebin'
host: 'pastebin',
},
sourceforge: {
fullName: 'Sourceforge',
favicon: 'sourceforge-favicon.ico',
host: 'sourceforge'
}
host: 'sourceforge',
},
};

export function getHostData(host: SupportedHostings) {
Expand Down
6 changes: 3 additions & 3 deletions packages/common/LocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ export const initialStorage: LocalStorage = {
gitlab: true,
bitbucket: true,
pastebin: false,
sourceforge: true
}
sourceforge: true,
},
};

export function getStorage(): Promise<LocalStorage> {
return new Promise((resolve, reject) => {
if (chrome.storage === undefined) {
reject(new Error('Storage is not accessible from this part of extension'));
}
chrome.storage.local.get(storage => {
chrome.storage.local.get((storage) => {
const store = storage as LocalStorage;
if (store.version === undefined) {
// When version doesn't exists, it means that storage is empty and user is running
Expand Down
2 changes: 1 addition & 1 deletion packages/common/Messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Message =

export function sendMessage(message: Message) {
return new Promise((resolve, _) => {
chrome.runtime.sendMessage(message, response => {
chrome.runtime.sendMessage(message, (response) => {
resolve(response);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/content/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { initSourceForge } from './pages/SourceForge';

const hostLocation = location.host;

(async function() {
(async function () {
const storage = (await sendMessage({ type: 'STORAGE_GET' })) as LocalStorage;
const hosts = Object.keys(storage.showIcons) as SupportedHostings[];
for (const host of hosts) {
Expand Down
86 changes: 44 additions & 42 deletions packages/content/pages/GitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getIconUrl,
DEFAULT_ROOT_OPENED,
DEFAULT_ROOT,
DEFAULT_FILE
DEFAULT_FILE,
} from '../utils/Icons';
import { isCommit, isRepoRoot, isSingleFile, isRepoTree } from 'github-url-detection';
import { isHistoryForFile } from '../utils/PageDetect';
Expand Down Expand Up @@ -58,49 +58,51 @@ function showIconsForSegments() {
* Show icons for repository files
*/
function showRepoTreeIcons(rowEl: Element) {
const iconEl = rowEl.children[0] as HTMLTableCellElement;
const iconSVGEl = iconEl.querySelector<SVGElement>('.octicon');
if (!iconSVGEl) {
// ... (up)
return;
}
/**
* <div role="row">
* <div><svg class={{icon}}/></div>,
* <div><span><a>{{name}}</a></span></div>,
* <div><span><a>{{message}}</a></span></div>,
* <div><span>{time}</span><s/div>,
* </div>
*/
const contentEl = rowEl.children[1] as Element;
const iconEl = rowEl.children[0] as HTMLTableCellElement;
const iconSVGEl = iconEl.querySelector<SVGElement>('.octicon');
if (!iconSVGEl) {
// ... (up)
return;
}
/**
* <div role="row">
* <div><svg class={{icon}}/></div>,
* <div><span><a>{{name}}</a></span></div>,
* <div><span><a>{{message}}</a></span></div>,
* <div><span>{time}</span><s/div>,
* </div>
*/
const contentEl = rowEl.children[1] as Element;

const linkToEl = contentEl.firstElementChild.firstElementChild as HTMLAnchorElement;
const linkToEl = contentEl.firstElementChild.firstElementChild as HTMLAnchorElement;

let iconPath = '';
if (iconSVGEl) {
const iconSVGClassName = iconSVGEl.className.baseVal;
if (iconSVGClassName.includes('octicon-file-text') || iconSVGClassName.includes('octicon-file ')) {
iconPath = getFileIcon(linkToEl.innerText.toLowerCase());
} else if (iconSVGClassName.includes('octicon-file-directory')) {
const name = linkToEl.innerText.toLowerCase();
iconPath = getFolderIcon(name.split('/').shift());
} else if (iconSVGClassName.includes('octicon-file-submodule')) {
iconPath = getIconForFolder('submodules');
} else if (iconSVGClassName.includes('octicon-file-symlink-file')) {
iconPath = DEFAULT_FILE;
} else if (iconSVGClassName.includes('octicon-file-symlink-directory')) {
iconPath = DEFAULT_FILE;
} else {
console.error(`Unknown filetype: "${iconSVGClassName}", please report`);
return;
}
const x = mutate(() => {
iconSVGEl.outerHTML = `<img src="${getIconUrl(iconPath)}" class="vscode-icon ${iconSVGClassName}" alt="icon" width="16" height="16">`;
});
let iconPath = '';
if (iconSVGEl) {
const iconSVGClassName = iconSVGEl.className.baseVal;
if (iconSVGClassName.includes('octicon-file-text') || iconSVGClassName.includes('octicon-file ')) {
iconPath = getFileIcon(linkToEl.innerText.toLowerCase());
} else if (iconSVGClassName.includes('octicon-file-directory')) {
const name = linkToEl.innerText.toLowerCase();
iconPath = getFolderIcon(name.split('/').shift());
} else if (iconSVGClassName.includes('octicon-file-submodule')) {
iconPath = getIconForFolder('submodules');
} else if (iconSVGClassName.includes('octicon-file-symlink-file')) {
iconPath = DEFAULT_FILE;
} else if (iconSVGClassName.includes('octicon-file-symlink-directory')) {
iconPath = DEFAULT_FILE;
} else {
console.error(`Unknown filetype: "${iconSVGClassName}", please report`);
return;
}
// else {
// console.error(`Error during parsing: "td.icon > svg.octoicon" doesnt exists for ${i}. row`);
// }
const x = mutate(() => {
iconSVGEl.outerHTML = `<img src="${getIconUrl(
iconPath
)}" class="vscode-icon ${iconSVGClassName}" alt="icon" width="16" height="16">`;
});
}
// else {
// console.error(`Error during parsing: "td.icon > svg.octoicon" doesnt exists for ${i}. row`);
// }
}

function update(e?: any) {
Expand All @@ -115,7 +117,7 @@ export function initGithub() {
observe(QUERY_FILE_TABLE_ITEMS, {
add(rowEl) {
showRepoTreeIcons(rowEl);
}
},
});
update();
document.addEventListener('pjax:end', update); // Update on page change
Expand Down
2 changes: 1 addition & 1 deletion packages/content/pages/PasteBin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function showIconForPaste() {
// TODO:
}

const domLoaded = new Promise(resolve => {
const domLoaded = new Promise((resolve) => {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', resolve);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/content/utils/Dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const load = (): Items => {
} else {
return {
files: {},
folders: {}
folders: {},
};
}
};
2 changes: 1 addition & 1 deletion packages/content/utils/Icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {
DEFAULT_FOLDER,
DEFAULT_FOLDER_OPENED,
DEFAULT_ROOT_OPENED,
DEFAULT_ROOT
DEFAULT_ROOT,
} from 'vscode-icons-js';
import { DEFAULT_FILE } from 'vscode-icons-js';

Expand Down
2 changes: 1 addition & 1 deletion packages/content/utils/showIconsForHosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function showIconsForHosting(host: SupportedHostings) {
github: initGithub,
gitlab: initGitLab,
pastebin: initPasteBin,
sourceforge: initSourceForge
sourceforge: initSourceForge,
};
funcsToShowIcons[host]();
}
Loading