Skip to content

Commit

Permalink
release: 1.0.9 (#340)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: sebastienfontaine <hello@sebastienfontaine.me>
Co-authored-by: sebastienfontaine <45472257+sebastienfontaine@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 7, 2024
1 parent 7c730b9 commit 25ccd92
Show file tree
Hide file tree
Showing 10 changed files with 773 additions and 744 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# <img src="public/assets/icon_16.png" alt="icon"> Tab Modifier

![GitHub Release](https://img.shields.io/github/v/release/furybee/chrome-tab-modifier?style=flat-square&labelColor=black) [![license](https://img.shields.io/badge/license-MIT-ff4081.svg?style=flat-square&labelColor=black)](./LICENSE) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/furybee/chrome-tab-modifier/ci.yml?style=flat-square&label=CI&labelColor=black) [![.nvmrc](https://img.shields.io/badge/.nvmrc-18-00e676.svg?style=flat-square&labelColor=black)](./.nvmrc)
![GitHub Release](https://img.shields.io/github/v/release/furybee/chrome-tab-modifier?style=flat-square&labelColor=black) [![license](https://img.shields.io/badge/license-MIT-ff4081.svg?style=flat-square&labelColor=black)](./LICENSE) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/furybee/chrome-tab-modifier/ci.yml?style=flat-square&label=CI&labelColor=black) [![.nvmrc](https://img.shields.io/badge/.nvmrc-20-00e676.svg?style=flat-square&labelColor=black)](./.nvmrc)
[![yarn:required](https://img.shields.io/badge/yarn-required-aeea00.svg?style=flat-square&labelColor=black)](https://yarnpkg.com/en/)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-ffab00.svg?style=flat-square&labelColor=black)](https://conventionalcommits.org) ![pr welcome](https://img.shields.io/badge/PRs-welcome-09FF33.svg?style=flat-square&labelColor=black)

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Tab Modifier",
"version": "1.0.8",
"version": "1.0.9",
"description": "Take control of your tabs",
"homepage_url": "https://github.com/furybee/chrome-tab-modifier",
"action": {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tab-modifier",
"private": true,
"version": "1.0.8",
"version": "1.0.9",
"type": "module",
"scripts": {
"test": "vitest --run",
Expand All @@ -23,7 +23,7 @@
"devDependencies": {
"@crxjs/vite-plugin": "^2.0.0-beta.23",
"@types/chrome": "^0.0.268",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.4.0",
"@vitejs/plugin-vue": "^5.0.5",
"@vitest/coverage-v8": "^1.6.0",
Expand All @@ -39,15 +39,15 @@
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-vue": "^9.24.0",
"eslint-plugin-vue": "^9.26.0",
"jsdom": "^24.1.0",
"postcss": "^8.4.38",
"prettier": "^3.3.1",
"prettier": "^3.3.2",
"tailwindcss": "^3.4.4",
"typescript": "*",
"vite": "^5.2.0",
"vitest": "^1.6.0",
"vue-eslint-parser": "^9.4.2",
"vue-tsc": "^2.0.6"
"vue-tsc": "^2.0.24"
}
}
7 changes: 6 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ async function applyGroupRuleToTab(

if (!tmGroup) return;

const tabGroupsQueryInfo = { title: tmGroup.title, windowId: tab.windowId };
const tabGroupsQueryInfo = {
title: tmGroup.title,
color: tmGroup.color,
collapsed: tmGroup.collapsed,
windowId: tab.windowId,
};

chrome.tabGroups.query(tabGroupsQueryInfo, (groups: chrome.tabGroups.TabGroup[]) =>
handleTabGroups(groups, tab, tmGroup)
Expand Down
38 changes: 1 addition & 37 deletions src/components/options/center/sections/TabRules/TableRules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
<th scope="col">Title</th>
<th scope="col">Detection</th>
<th scope="col">URL Fragment</th>
<th scope="col"></th>
<th scope="col" class="text-right">
<RefreshButton @on-refresh-click="refresh"></RefreshButton>
</th>
</tr>
</thead>
<draggable v-model="rules" tag="tbody" item-key="id" @end="onDragEnd">
<template #item="{ element: rule, index }">
<template #item="{ element: rule }">
<tr class="group cursor-pointer hover:bg-base-100" @click="editRule(rule)">
<td scope="row">{{ rule.name }}</td>
<td>
Expand Down Expand Up @@ -44,27 +43,6 @@
{{ _shortify(rule.url_fragment, 20) }}
</div>
</td>
<td>
<div class="flex gap-4 invisible group-hover:visible overflow-hidden">
<button
class="btn btn-xs btn-circle tooltip flex items-center justify-items-center"
:class="{ invisible: index === 0 }"
data-tip="Move Up"
@click.prevent="(event) => moveUp(event, rule.id)"
>
<ArrowUpIcon class="!w-4 !h-4" />
</button>

<button
class="btn btn-xs btn-circle tooltip flex items-center justify-items-center"
:class="{ invisible: index === props.rules.length - 1 }"
data-tip="Move Down"
@click.prevent="(event) => moveDown(event, rule.id)"
>
<ArrowDownIcon class="!w-4 !h-4" />
</button>
</div>
</td>
<td>
<div class="flex justify-end gap-8 invisible group-hover:visible overflow-hidden">
<button
Expand Down Expand Up @@ -100,8 +78,6 @@ import RefreshButton from '../../../../global/RefreshButton.vue';
import { _chromeGroupColor, _shortify } from '../../../../../common/helpers.ts';
import ColorVisualizer from '../TabGroups/ColorVisualizer.vue';
import { computed, watch } from 'vue';
import ArrowDownIcon from '../../../../icons/ArrowDownIcon.vue';
import ArrowUpIcon from '../../../../icons/ArrowUpIcon.vue';
import draggable from 'vuedraggable';
const props = defineProps<{
Expand Down Expand Up @@ -159,18 +135,6 @@ const duplicateRule = async (event: MouseEvent, ruleId: string) => {
rules.value = [...rulesStore.rules]; // Update the rules array after duplication
};
const moveUp = async (event: MouseEvent, ruleId: string) => {
event.stopPropagation();
await rulesStore.moveUp(ruleId);
rules.value = [...rulesStore.rules]; // Update the rules array after moving up
};
const moveDown = async (event: MouseEvent, ruleId: string) => {
event.stopPropagation();
await rulesStore.moveDown(ruleId);
rules.value = [...rulesStore.rules]; // Update the rules array after moving down
};
const deleteRule = async (event: MouseEvent, ruleId: string) => {
event.stopPropagation();
if (confirm('Are you sure you want to delete this rule?')) {
Expand Down
29 changes: 27 additions & 2 deletions src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,33 @@ export function updateTitle(title, tag, value) {
}

export function getTextBySelector(selector) {
let el = document.querySelector(selector),
value = '';
let el = null;

if (selector.includes('*')) {
const parts = selector.split(' ');

const modifiedParts = parts.map((part) => {
if (part.includes('*')) {
if (part.startsWith('.')) {
return `[class*="${part.replace('.', '').replace('*', '')}"]`;
} else {
return `[${part.replace('*', '')}]`;
}
}
return part;
});

const modifiedSelector = modifiedParts.join(' ');
const elements = document.querySelectorAll(modifiedSelector);

if (elements.length > 0) {
el = elements[0];
}
} else {
el = document.querySelector(selector);
}

let value = '';

if (el) {
if (el.childNodes.length > 0) {
Expand Down
86 changes: 82 additions & 4 deletions src/content.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,68 @@ describe('Content', () => {
expect(result).toBe('Hello');
});

it('should get value from an input element', () => {
document.body.innerHTML = '<input id="test" value="Hello">';
const result = getTextBySelector('#test');
expect(result).toBe('Hello');
it('should get value from an nested input element', () => {
document.body.innerHTML = `<div id="header-search-form">
<div>
<form id="search" action="#" method="get">
<input type="text" id="q" name="q" value="bar" placeholder="Search...">
<button type="submit">Search</button>
</form>
</div>
</div>`;

const result = getTextBySelector('div#header-search-form div form#search input#q');
expect(result).toBe('bar');
});

it('should get value with a wildcard', () => {
document.body.innerHTML = `<div
class="devices-module-link--1j5_7Hi7 devices-module-large--1IiO3pLC devices-module-machineName--vVcUTm3t"
title="WKS-SCOTTB02">
WKS-SCOTTB02
</div>`;

const result = getTextBySelector('.devices-module-machineName*');
expect(result).toBe('WKS-SCOTTB02');
});

it('should get value with a wildcard in container id', () => {
document.body.innerHTML = `<div id="container">
<div
class="devices-module-link--1j5_7Hi7 devices-module-large--1IiO3pLC devices-module-machineName--vVcUTm3t"
title="WKS-SCOTTB02">
WKS-SCOTTB02
</div>
</div>`;

const result = getTextBySelector('#container .devices-module-machineName*');
expect(result).toBe('WKS-SCOTTB02');
});

it('should get value with a wildcard in container div', () => {
document.body.innerHTML = `<div>
<div
class="devices-module-link--1j5_7Hi7 devices-module-large--1IiO3pLC devices-module-machineName--vVcUTm3t"
title="WKS-SCOTTB02">
WKS-SCOTTB02
</div>
</div>`;

const result = getTextBySelector('div > .devices-module-machineName*');
expect(result).toBe('WKS-SCOTTB02');
});

it('should not return value with a wildcard & wrong selector', () => {
document.body.innerHTML = `<p>
<span
class="devices-module-link--1j5_7Hi7 devices-module-large--1IiO3pLC devices-module-machineName--vVcUTm3t"
title="WKS-SCOTTB02">
WKS-SCOTTB02
</span>
</p>`;

const result = getTextBySelector('div > .devices-module-machineName*');
expect(result).toBe('');
});

it('should return empty string if element is not found', () => {
Expand Down Expand Up @@ -107,6 +165,26 @@ describe('Content', () => {
expect(result).toBe('john@gmail.com | mail.google.com');
});

it('should process title with URL matcher - procore', async () => {
const rule = {
tab: {
title: '{title} $1',
detection: 'REGEX',
url_fragment: 'app[.]procore[.]com/754712/project/daily_log/list?',
url_matcher: 'date=[0-9]{4}-([0-9]{2}-[0-9]{2})',
},
};

document.title = 'GMP1';

const result = processTitle(
'app.procore.com/754712/project/daily_log/list?date=2021-07-01',
'GMP1',
rule
);
expect(result).toBe('GMP1 07-01');
});

it('should match github repositories', () => {
const rule = {
tab: {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.tsbuildinfo

Large diffs are not rendered by default.

Loading

0 comments on commit 25ccd92

Please sign in to comment.