Skip to content

Commit

Permalink
feat: update the meta json for monkey scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Arylo committed Jun 19, 2024
1 parent 0ce7a28 commit d3b83ac
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
18 changes: 0 additions & 18 deletions README

This file was deleted.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Scripts for Arylo

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 |
|nyaa-si-show-image |In some scenarios show image on the `nyaa.si` |

## Qinglong Scripts

|Script |Description |
|-- |-- |
|groupVideo|Classification and storage for video files|
|moveVideo |Move video files to the target folder |
2 changes: 2 additions & 0 deletions etc/build/monkey.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { githubInfo } from '../consts'
export const bannerOrderMap = {
head: [
'name',
/^name:\w+$/,
'namespace',
'copyright',
'description',
/^description:\w+/,
'icon',
'iconURL',
'defaulticon',
Expand Down
14 changes: 12 additions & 2 deletions etc/build/monkey.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ const parseMetaItem = (key: string, value: any) => {
}
}

const findIndex = (val: string, rules: Array<string|RegExp> = []) => {
return rules.findIndex((rule) => {
if (rule instanceof RegExp) {
return rule.test(val)
} else {
return rule === val
}
})
}

export const paresBanner = (filepath: string, appendInfo = {}) => {
const jsonPath = parseJsonPath(filepath)
const jsonContent = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'))
Expand All @@ -51,8 +61,8 @@ export const paresBanner = (filepath: string, appendInfo = {}) => {
.sort(([key1], [key2]) => {
const orderHead = bannerOrderMap.head
const orderTail = bannerOrderMap.tail
const key1Order = [...orderHead, ...orderTail].indexOf(key1)
const key2Order = [...orderHead, ...orderTail].indexOf(key2)
const key1Order = findIndex(key1, [...orderHead, ...orderTail])
const key2Order = findIndex(key2, [...orderHead, ...orderTail])

let result = -1
if (key1Order !== -1 && key2Order !== -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/monkey/gitlab-font-family.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Add Font Family for Gitlab",
"version": "1.3",
"name": "Add Font Family for the Self-managed Gitlab",
"name:zh": "为自托管 Gitlab 添加字体",
"include": [
"/^https:\/\/git\\b.[^\/]+\/.*\/-\/raw\/.*/",
"/^https:\/\/git\\b.[^\/]+\/.*\/-\/blob\/.*/",
Expand Down
4 changes: 2 additions & 2 deletions src/monkey/gitlab-settings-max-size.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Max Size CI/CD Setting Page for Gitlab",
"version": "1.3",
"name": "Max Size CI/CD Setting Page for the Self-managed Gitlab",
"name:zh": "自托管 Gitlab CI/CD 设置页面最大化尺寸",
"include": "/^https:\/\/git\\b.[^\/]+\/.*\/-\/settings\/ci_cd$/",
"run-at": "document-end",
"grant": "GM_addStyle"
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/nyaa-si-show-image.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "Display image right now in nyaa.si",
"name:zh": "在nyaa.si 上立即显示图片",
"match": "https://sukebei.nyaa.si/view/*",
"grant": "none",
"version": "1.0",
"run-at": "document-end",
"require": "https://code.jquery.com/jquery-3.6.0.min.js"
}

0 comments on commit d3b83ac

Please sign in to comment.