-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
413 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,170 @@ | ||
# Scripts for Arylo | ||
|
||
[](https://github.com/arylo/scripts/) | ||
|
||
This project contains scripts that are useful for Arylo's daily tasks. | ||
|
||
## Monkey Scripts | ||
|
||
|Script |Description | | ||
|-- |-- | | ||
|gitlab-font-family |Replace the font family in the merge request page | | ||
|~~gitlab-settings-max-size~~|~~Expand the page size in the CI/CD settings page~~| | ||
|gitlab-enhance |Enhance some features of the Self-managed Gitlab | | ||
|nyaa-si-show-image |In some scenarios show image on the `nyaa.si` | | ||
|copymanga-enhance |Enhance UX for copy manga comic page | | ||
|Script |Description |Install | | ||
|-- |-- |-- | | ||
|gitlab-font-family |Replace the font family in the merge request page |[Jump](#change-gitlab-font)| | ||
|~~gitlab-settings-max-size~~|~~Expand the page size in the CI/CD settings page~~|~~[Jump](#max-size-for-gitlab-setting-page)~~ | | ||
|gitlab-enhance |Enhance some features of the Self-managed Gitlab |[Jump](#enhance-ux-for-the-self-managed-gitlab)| | ||
|nyaa-si-show-image |In some scenarios show image on the `nyaa.si` |[Jump](#auto-show-the-source-image-for-nyaasi)| | ||
|copymanga-enhance |Enhance UX for copy manga comic page |[Jump](#enhance-ux-for-copy-manga-comic-sites)| | ||
|
||
### Change Gitlab Font | ||
|
||
[Top](#monkey-scripts) | ||
|
||
#### Install Addresses | ||
|
||
[Github][gitlab-font-family_github] | ||
|
||
[gitlab-font-family_github]: https://raw.githubusercontent.com/Arylo/scripts/monkey/gitlab-font-family.user.js | ||
|
||
#### Description | ||
|
||
![GitHub last commit][gitlab-font-family_github-last-update] | ||
|
||
[gitlab-font-family_github-last-update]: https://img.shields.io/github/last-commit/arylo/scripts/monkey?path=gitlab-font-family.user.js&style=flat&label=Last%20Update | ||
|
||
Replace the font family in the merge request page | ||
|
||
#### Compatibility | ||
|
||
| |TamperMonkey|ViolentMonkey|Stay 2 |Userscripts | | ||
|-- |-- |-- |-- |-- | | ||
|Chrome |![][pass] |![][unknown] |![][unknown]|![][unknown]| | ||
|Firefox |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari(iOS) |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Edge(Chromium)|![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|
||
### Max Size for Gitlab setting page | ||
|
||
[Top](#monkey-scripts) | ||
|
||
#### Install Addresses | ||
|
||
[Github][gitlab-settings-max-size_github] | ||
|
||
[gitlab-settings-max-size_github]: https://raw.githubusercontent.com/Arylo/scripts/monkey/gitlab-settings-max-size.user.js | ||
|
||
#### Description | ||
|
||
![GitHub last commit][gitlab-settings-max-size_github-last-update] | ||
|
||
[gitlab-settings-max-size_github-last-update]: https://img.shields.io/github/last-commit/arylo/scripts/monkey?path=gitlab-settings-max-size.user.js&style=flat&label=Last%20Update | ||
|
||
Expand the page size in the CI/CD settings page | ||
|
||
#### Compatibility | ||
|
||
| |TamperMonkey|ViolentMonkey|Stay 2 |Userscripts | | ||
|-- |-- |-- |-- |-- | | ||
|Chrome |![][pass] |![][unknown] |![][unknown]|![][unknown]| | ||
|Firefox |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari(iOS) |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Edge(Chromium)|![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|
||
### Enhance UX for the self-managed Gitlab | ||
|
||
[Top](#monkey-scripts) | ||
|
||
#### Install Addresses | ||
|
||
[GreasyFork][gitlab-enhance_greasyfork] | [Github][gitlab-enhance_github] | ||
|
||
[gitlab-enhance_greasyfork]: https://update.greasyfork.org/scripts/519026/Enhance%20some%20features%20of%20the%20Self-managed%20Gitlab.user.js | ||
[gitlab-enhance_github]: https://raw.githubusercontent.com/Arylo/scripts/monkey/gitlab-enhance.user.js | ||
|
||
#### Description | ||
|
||
![GitHub last commit][gitlab-enhance_github-last-update] | ||
|
||
[gitlab-enhance_github-last-update]: https://img.shields.io/github/last-commit/arylo/scripts/monkey?path=gitlab-enhance.user.js&style=flat&label=Last%20Update | ||
|
||
Enhance some features of the Self-managed Gitlab | ||
|
||
#### Compatibility | ||
|
||
| |TamperMonkey|ViolentMonkey|Stay 2 |Userscripts | | ||
|-- |-- |-- |-- |-- | | ||
|Chrome |![][pass] |![][unknown] |![][unknown]|![][unknown]| | ||
|Firefox |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari(iOS) |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Edge(Chromium)|![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|
||
### Auto show the source image for nyaa.si | ||
|
||
[Top](#monkey-scripts) | ||
|
||
#### Install Addresses | ||
|
||
[Github][nyaa-si-show-image_github] | ||
|
||
[nyaa-si-show-image_github]: https://raw.githubusercontent.com/Arylo/scripts/monkey/nyaa-si-show-image.user.js | ||
|
||
#### Description | ||
|
||
![GitHub last commit][nyaa-si-show-image_github-last-update] | ||
|
||
[nyaa-si-show-image_github-last-update]: https://img.shields.io/github/last-commit/arylo/scripts/monkey?path=nyaa-si-show-image.user.js&style=flat&label=Last%20Update | ||
|
||
In some scenarios show image on the `nyaa.si` | ||
|
||
#### Compatibility | ||
|
||
| |TamperMonkey|ViolentMonkey|Stay 2 |Userscripts | | ||
|-- |-- |-- |-- |-- | | ||
|Chrome |![][pass] |![][unknown] |![][unknown]|![][unknown]| | ||
|Firefox |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari(iOS) |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Edge(Chromium)|![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|
||
### Enhance UX for copy manga comic sites | ||
|
||
[Top](#monkey-scripts) | ||
|
||
#### Install Addresses | ||
|
||
[Github][copymanga-enhance_github] | ||
|
||
[copymanga-enhance_github]: https://raw.githubusercontent.com/Arylo/scripts/monkey/copymanga-enhance.user.js | ||
|
||
#### Description | ||
|
||
![GitHub last commit][copymanga-enhance_github-last-update] | ||
|
||
[copymanga-enhance_github-last-update]: https://img.shields.io/github/last-commit/arylo/scripts/monkey?path=copymanga-enhance.user.js&style=flat&label=Last%20Update | ||
|
||
Enhance UX for copy manga comic page | ||
|
||
#### Compatibility | ||
|
||
| |TamperMonkey|ViolentMonkey|Stay 2 |Userscripts | | ||
|-- |-- |-- |-- |-- | | ||
|Chrome |![][pass] |![][unknown] |![][unknown]|![][unknown]| | ||
|Firefox |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Safari(iOS) |![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|Edge(Chromium)|![][unknown]|![][unknown] |![][unknown]|![][unknown]| | ||
|
||
[pass]: https://img.shields.io/badge/-pass-green.svg?&logoColor=000&style=for-the-badge&cacheSeconds=7200 | ||
[unknown]: https://img.shields.io/badge/-unknown-silver.svg?&logoColor=000&style=for-the-badge&cacheSeconds=7200 | ||
|
||
## Qinglong Scripts | ||
|
||
|Script |Description | | ||
|-- |-- | | ||
|groupVideo|Classification and storage for video files| | ||
|moveVideo |Move video files to the target folder | | ||
|
||
## License | ||
|
||
[The MIT License.](https://github.com/Arylo/scripts/?tab=MIT-1-ov-file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
{ | ||
"name": "Enhance some features of the Self-managed Gitlab", | ||
"name:zh": "强化自托管 Gitlab 能力", | ||
"description": "Enhance some features of the Self-managed Gitlab, such as the CI/CD settings page, the merge request create/edit page etc.", | ||
"description:zh": "强化自托管 Gitlab 的一些功能,如 CI/CD 设置页面、合并请求创建/编辑页面等。", | ||
"icon": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGhlaWdodD0iNTEycHgiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDUxMiA1MTI7IiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiB3aWR0aD0iNTEycHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnIGlkPSJfeDMxXzQ0LWdpdGxhYiI+PGc+PGcgaWQ9IlhNTElEXzZfIj48Zz48Zz48cGF0aCBkPSJNNTIuNzUyLDIwNS41MDFsMjAzLjE4LDI2NC4wN2wtMjIyLjctMTY1LjI5Yy02LjExLTQuNTktOC43Mi0xMi41OC02LjM4LTE5Ljc3MWwyNS44Ny03OS4wNSAgICAgICBMNTIuNzUyLDIwNS41MDF6IiBzdHlsZT0iZmlsbDojRkNBMzI2OyIvPjwvZz48Zz48cG9seWdvbiBwb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AgICAgICBDMTIwLjU1Miw0OC40MjEsMTcxLjMwMiwyMDUuNDYxLDE3MS4zOTIsMjA1LjQ2MXoiIHN0eWxlPSJmaWxsOiNFMjQzMjk7Ii8+PC9nPjwvZz48L2c+PC9nPjwvZz48ZyBpZD0iTGF5ZXJfMSIvPjwvc3ZnPg==", | ||
"include": [ | ||
"/^https:\\/\\/(git(lab)?|code)\\.[^\/]+\\/.*\\/-\\/settings\\/ci_cd$/", | ||
"/^https:\\/\\/(git(lab)?|code)\\.[^\/]+\\/.*\\/-\\/merge_requests\\/new\\b/", | ||
"/^https:\\/\\/(git(lab)?|code)\\.[^\/]+\\/.*\\/-\\/merge_requests\\/\\d+\/edit\\b/", | ||
"/^https:\\/\\/(git(lab)?|code)\\.[^\/]+\\/dashboard\\/merge_requests\\b/" | ||
], | ||
"run-at": "document-end", | ||
"grant": [ | ||
"GM_addStyle" | ||
"GM_addStyle", | ||
"GM_setClipboard" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import './settings/ci_cd' | ||
import './dashboard/merge_requests' | ||
import './merge_requests/new' | ||
import './merge_requests/edit' | ||
|
||
export {} |
22 changes: 22 additions & 0 deletions
22
src/monkey/gitlab-enhance/merge_requests/__snapshots__/templateUtls.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`genTemplate > Default empty content 1`] = `""`; | ||
|
||
exports[`genTemplate > Reusing deep utils 1`] = ` | ||
"## 123 | ||
- item 1 | ||
- item 2 | ||
### 456 | ||
" | ||
`; | ||
|
||
exports[`genTemplate > Reusing utils 1`] = ` | ||
"## 123 | ||
### 456 | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { appendTemplateButton } from "./template" | ||
|
||
if (/\/-\/merge_requests\/\d+\/edit$/.test(location.pathname)) { | ||
setTimeout(() => { | ||
appendTemplateButton() | ||
}, 1000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getButtonElement } from "../utils" | ||
import { appendTemplateButton } from "./template" | ||
|
||
const appendAsTitleButton = () => { | ||
$('.commit-content').each((_, el) => { | ||
const titleElements = $('.item-title', el) | ||
const title = titleElements.text() | ||
const btnElement = getButtonElement('As title') | ||
btnElement.on('click', () => { | ||
$('input[data-testid=issuable-form-title-field]').val(title) | ||
$('input[data-testid=issuable-form-title-field]').focus() | ||
}) | ||
$('.committer', el).before(btnElement) | ||
}) | ||
} | ||
|
||
|
||
if (location.pathname.endsWith('/-/merge_requests/new')) { | ||
setTimeout(() => { | ||
appendTemplateButton() | ||
appendAsTitleButton() | ||
}, 1000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.gl-display-flex:has([for=merge_request_description]) { | ||
align-items: baseline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import * as templateUtils from './templateUtils' | ||
import templateCss from './template.css' | ||
import { getButtonElement } from '../utils' | ||
|
||
enum BRANCH_TYPE { | ||
FEATURE, | ||
BUGFIX, | ||
HOTFIX, | ||
TASKS, | ||
OTHERS, | ||
} | ||
|
||
const getBranchType = () => { | ||
const fromBranchName = $('.align-self-center code:not([data-branch-name])').text() | ||
const prefixBranchName = fromBranchName.split('/')[0].toLowerCase() | ||
switch (prefixBranchName) { | ||
case 'feature': | ||
case 'feat': | ||
return BRANCH_TYPE.FEATURE | ||
case 'fix': | ||
case 'bugfix': | ||
return BRANCH_TYPE.BUGFIX | ||
case 'hotfix': | ||
return BRANCH_TYPE.HOTFIX | ||
case 'devops': | ||
case 'chore': | ||
case 'test': | ||
case 'doc': | ||
case 'docs': | ||
return BRANCH_TYPE.TASKS | ||
default: | ||
return BRANCH_TYPE.OTHERS | ||
} | ||
} | ||
|
||
const generateTemplate = () => { | ||
const branchType = getBranchType() | ||
return templateUtils.genTemplate((utils) => { | ||
utils.h2('Type') | ||
.taskItem('Feature (Story/Refactor)', { selected: branchType === BRANCH_TYPE.FEATURE }) | ||
.taskItem(`Bugfix`, { selected: branchType === BRANCH_TYPE.BUGFIX }) | ||
.taskItem(`Hotfix (Production Issues)`, { selected: branchType === BRANCH_TYPE.HOTFIX }) | ||
.taskItem(`Tasks (DevOps / Unit Test / Document Update)`, { selected: branchType === BRANCH_TYPE.TASKS }) | ||
.taskItem(`Others`, { selected: branchType === BRANCH_TYPE.OTHERS }) | ||
.end() | ||
|
||
utils.h2('Description') | ||
if (branchType !== BRANCH_TYPE.FEATURE) { | ||
utils.h3('Why (Why does this happen?)') | ||
.listItem() | ||
.end() | ||
|
||
utils.h3('How (How can we avoid or solve it?)') | ||
.listItem() | ||
.end() | ||
} | ||
|
||
utils.h3('What (What did you do this time?)') | ||
.listItem() | ||
.end() | ||
|
||
if (branchType !== BRANCH_TYPE.TASKS) { | ||
utils.h3('Results (Screenshot, etc)') | ||
utils.h4('Before modification') | ||
utils.h4('After modification') | ||
|
||
utils.h2('Affected Zone') | ||
.listItem('Affected Module(s):') | ||
.listItem('Affected URL(s):') | ||
.end() | ||
} | ||
|
||
utils.h2('External resources (Mention, Resolves, or Closes)') | ||
}) | ||
} | ||
|
||
export const appendTemplateButton = () => { | ||
GM_addStyle(templateCss) | ||
const text = 'Copy Template' | ||
const btnElement = getButtonElement(text) | ||
const templateContent = generateTemplate() | ||
const hint = $('<span class="gl-font-sm! gl-ml-3 gl-text-secondary"></span>') | ||
let setTimeoutId: NodeJS.Timeout | undefined | ||
btnElement.on('click', async () => { | ||
hint.remove() | ||
setTimeoutId && clearTimeout(setTimeoutId) | ||
hint.text('Copying...') | ||
btnElement.after(hint) | ||
await GM_setClipboard(templateContent, 'text', () => { | ||
hint.text('Copied!') | ||
setTimeoutId = setTimeout(() => hint.remove(), 3000) | ||
}) | ||
}) | ||
|
||
$('.gl-display-flex:has([for=merge_request_description])').append(btnElement) | ||
} |
Oops, something went wrong.