-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: switch to
@include
rules because @match
is too limited
- Loading branch information
Showing
12 changed files
with
163 additions
and
97 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
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,13 +1,13 @@ | ||
import type { UserscriptMetadata } from '@lib/util/metadata'; | ||
import { MB_EDIT_PAGE_PATHS, transformMBMatchURL } from '@lib/util/metadata'; | ||
import { MB_EDIT_DISPLAY_PAGE_PATTERNS } from '@lib/util/metadata'; | ||
|
||
const metadata: UserscriptMetadata = { | ||
name: 'MB: Blind Votes', | ||
description: 'Blinds editor details before your votes are cast.', | ||
// FIXME: This should run at document-start to ensure that editor details | ||
// don't flash onto the screen while the page is still loading. | ||
'run-at': 'document-end', | ||
match: MB_EDIT_PAGE_PATHS.map((path) => transformMBMatchURL(path)), | ||
include: MB_EDIT_DISPLAY_PAGE_PATTERNS, | ||
}; | ||
|
||
export default metadata; |
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
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,19 +1,14 @@ | ||
import type { UserscriptMetadata } from '@lib/util/metadata'; | ||
import { transformMBMatchURL } from '@lib/util/metadata'; | ||
import { createMBRegex as mb, MB_EDITABLE_ENTITIES, MBID_REGEX_PART as mbid } from '@lib/util/metadata'; | ||
|
||
const metadata: UserscriptMetadata = { | ||
name: 'MB: QoL: Paste multiple external links at once', | ||
description: 'Enables pasting multiple links, separated by whitespace, into the external link editor.', | ||
'run-at': 'document-end', | ||
match: [ | ||
'*/edit', | ||
'*/edit?*', | ||
'release/*/edit-relationships*', | ||
'*/add', | ||
'*/add?*', | ||
'*/create', | ||
'*/create?*', | ||
].map((path) => transformMBMatchURL(path)), | ||
include: [ | ||
mb`(${MB_EDITABLE_ENTITIES.join('|')})/(add|create|${mbid}/edit)`, | ||
mb`release/${mbid}/edit-relationships`, | ||
], | ||
}; | ||
|
||
export default metadata; |
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,16 +1,12 @@ | ||
import type { UserscriptMetadata } from '@lib/util/metadata'; | ||
import { transformMBMatchURL } from '@lib/util/metadata'; | ||
import { createMBRegex as mb, MBID_REGEX_PART as mbid } from '@lib/util/metadata'; | ||
|
||
const metadata: UserscriptMetadata = { | ||
// FIXME: This name isn't very descriptive. | ||
name: 'MB: QoL: Inline all recordings\' tracks on releases', | ||
description: 'Display all tracks and releases on which a recording appears from the release page.', | ||
'run-at': 'document-end', | ||
match: transformMBMatchURL('release/*'), | ||
exclude: [ | ||
transformMBMatchURL('release/add'), | ||
transformMBMatchURL('release/*/edit*'), | ||
], | ||
include: mb`release/${mbid}`, | ||
}; | ||
|
||
export default metadata; |
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,15 +1,11 @@ | ||
import type { UserscriptMetadata } from '@lib/util/metadata'; | ||
import { transformMBMatchURL } from '@lib/util/metadata'; | ||
import { createMBRegex as mb, MBID_REGEX_PART as mbid } from '@lib/util/metadata'; | ||
|
||
const metadata: UserscriptMetadata = { | ||
name: 'MB: QoL: Seed the batch recording comments script', | ||
description: 'Seed the recording comments for the batch recording comments userscripts with live and DJ-mix data.', | ||
'run-at': 'document-end', | ||
match: transformMBMatchURL('release/*'), | ||
exclude: [ | ||
transformMBMatchURL('release/add'), | ||
transformMBMatchURL('release/*/edit*'), | ||
], | ||
include: mb`release/${mbid}`, | ||
}; | ||
|
||
export default metadata; |
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,15 +1,11 @@ | ||
import type { UserscriptMetadata } from '@lib/util/metadata'; | ||
import { transformMBMatchURL } from '@lib/util/metadata'; | ||
import { createMBRegex as mb, MBID_REGEX_PART as mbid } from '@lib/util/metadata'; | ||
|
||
const metadata: UserscriptMetadata = { | ||
name: 'MB: QoL: Select All Update Recordings', | ||
description: 'Add buttons to release editor to select all "Update recordings" checkboxes.', | ||
'run-at': 'document-idle', | ||
match: [ | ||
'release/*/edit', | ||
'release/*/edit?*', | ||
'release/add*', | ||
].map((path) => transformMBMatchURL(path)), | ||
include: mb`release/(add|${mbid}/edit)`, | ||
}; | ||
|
||
export default metadata; |
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
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,8 +1,16 @@ | ||
import { transformMBMatchURL } from '@lib/util/metadata'; | ||
import { createMBRegex as mb } from '@lib/util/metadata'; | ||
|
||
describe('transforming match URLs', () => { | ||
describe('creating MB regexes', () => { | ||
it('should prefix MB domain', () => { | ||
expect(transformMBMatchURL('release/add')) | ||
.toBe('*://*.musicbrainz.org/release/add'); | ||
// Need to remove surrounding slashes | ||
const pattern = new RegExp(mb`release/add`.slice(1, -1)); | ||
|
||
expect(pattern.test('https://musicbrainz.org/release/add')).toBeTrue(); | ||
expect(pattern.test('https://beta.musicbrainz.org/release/add')).toBeTrue(); | ||
expect(pattern.test('https://musicbrainz.org/release/add?x=123')).toBeTrue(); | ||
expect(pattern.test('https://musicbrainz.org/release/add?x=123#fragment')).toBeTrue(); | ||
expect(pattern.test('https://musicbrainz.org/release/add#fragment')).toBeTrue(); | ||
expect(pattern.test('https://musicbrainz.org/release/add/123')).toBeFalse(); | ||
expect(pattern.test('https://musicbrainz.org/release/adda')).toBeFalse(); | ||
}); | ||
}); |