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
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dist
dist-ssr
build
built
*.local

# Logs
logs
Expand Down Expand Up @@ -47,5 +46,9 @@ xcuserdata/
*.xcuserstate
*.dev.xcconfig
XCBuildData
xcode/**/build/
xcode/**/dist/
xcode/Ext-Safari/Resources/

# directories and files
local
*.local
/scripts/*.local.js
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# root
/package
/public
/public/**/vendor
/etc

# dir
Expand Down
69 changes: 61 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,86 @@
}
},
{
"label": "npm: build",
"label": "npm: dev ext-safari-mac",
"detail": "Run dev server and build dev resource to xcode dist",
"type": "shell",
"command": "npm run dev:ext-safari-mac",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "npm: dev ext-safari-ios",
"detail": "Run dev server and build dev resource to xcode dist",
"type": "shell",
"command": "npm run dev:ext-safari-ios",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "npm: build mac",
"detail": "Build to xcode dist path",
"type": "shell",
"command": "npm run build",
"command": "npm run build:mac",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "xcode: build",
"detail": "xcodebuild",
"label": "npm: build ios",
"detail": "Build to xcode dist path",
"type": "shell",
"command": "xcodebuild -scheme Userscripts build",
"command": "npm run build:ios",
"group": "build",
"options": {
"cwd": "./"
}
},
{
"label": "xcodebuild: mac-debug",
"detail": "xcodebuild mac debug",
"type": "shell",
"command": "xcodebuild -scheme Mac -configuration Debug",
"group": "build",
"options": {
"cwd": "./xcode/"
}
},
{
"label": "xcodebuild: mac-vite",
"detail": "xcodebuild mac vite",
"type": "shell",
"command": "xcodebuild -scheme Mac-Vite-Dev -configuration Vite",
"group": "build",
"options": {
"cwd": "./xcode/"
}
},
{
"label": "build all",
"detail": "npm build + xcodebuild",
"label": "dev: ext-safari-mac",
"detail": "npm: dev ext-safari-mac + xcodebuild: mac-vite",
"presentation": {
"reveal": "silent"
},
"dependsOrder": "sequence",
"dependsOn": ["npm: dev ext-safari-mac", "xcodebuild: mac-vite"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build: mac debug",
"detail": "npm: build mac + xcodebuild: mac-debug",
"presentation": {
"reveal": "silent"
},
"dependsOrder": "sequence",
"dependsOn": ["npm: build", "xcode: build"],
"dependsOn": ["npm: build mac", "xcodebuild: mac-debug"],
"group": {
"kind": "build",
"isDefault": true
Expand Down
11 changes: 6 additions & 5 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ Reviewing the template will help you understand the composition of the project.

# Dev

- `npm install`[^1]
- `npm run dev`[^1]
- `npm install` [^1]
- `npm run dev` [^1]

# Build

- `npm run build`[^1]
- `npm run build:mac` [^1][^2]
- `cd ./xcode`
- `xcodebuild`[^1][^2] or build with `Xcode` App
- `xcodebuild -scheme Mac` [^1][^2][^3] or build with `Xcode` App

[^1]: These commands can also be executed directly through the vscode tasks. Please refer to: [/.vscode/tasks.json](../.vscode/tasks.json)
[^2]: Local setup may be required. Please refer to: [Building from the Command Line with Xcode FAQ](https://developer.apple.com/library/archive/technotes/tn2339/_index.html)
[^2]: Select the corresponding target and platform to build. Please refer to: [/package.json](../package.json) and [xcode-schemes](../xcode/Userscripts.xcodeproj/xcshareddata/xcschemes/)
[^3]: Local setup may be required. Please refer to: [Building from the Command Line with Xcode FAQ](https://developer.apple.com/library/archive/technotes/tn2339/_index.html)

# Xcode

Expand Down
9 changes: 9 additions & 0 deletions entry-ext-background.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>Userscripts background</title>
</head>
<body>
<script type="module" src="/src/ext/background/main.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion entry-ext-extension-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<noscript>Please enable Javascript to use this app</noscript>
<div id="app"></div>
<script type="module" src="/src/ext/extension-page/main.js"></script>
<script src="extension-page/jshint.min.js"></script>
<script src="jshint.min.js"></script>
</body>
</html>
44 changes: 33 additions & 11 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ import prettier from "eslint-config-prettier";
import globals from "globals";

export default [
// https://eslint.org/docs/latest/use/configure/configuration-files-new#using-predefined-configurations
// https://github.com/eslint/eslint/tree/main/packages/js
/**
* @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#using-predefined-configurations}
* @see {@link https://github.com/eslint/eslint/tree/main/packages/js}
*/
js.configs.recommended,

// https://github.com/sveltejs/eslint-plugin-svelte
// currently no official svelte/recommended flat config
// flatten and call it through a custom config object
/**
* @see {@link https://github.com/sveltejs/eslint-plugin-svelte}
* currently no official svelte/recommended flat config
* flatten and call it through a custom config object
*/
{
files: ["**/*.svelte"],
languageOptions: {
Expand All @@ -36,20 +40,38 @@ export default [
},
},

// https://github.com/prettier/eslint-config-prettier
// turns off the conflict rules, put it last
/**
* @see {@link https://github.com/prettier/eslint-config-prettier}
* turns off the conflict rules, put it last
*/
prettier,

// custom config objects
/** custom config objects */

// https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores
/** @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores} */
{
ignores: ["**/dist/", "**/build/", "etc/", "xcode/", "public/"],
},

// https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options
/** @see {@link https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options} */
{
files: ["src/**/*.{js,svelte}"],
files: ["scripts/**/*.js"],
languageOptions: {
globals: {
...globals.node,
},
},
},
{
files: ["src/{app,dev}/**/*.{js,svelte}"],
languageOptions: {
globals: {
...globals.browser,
},
},
},
{
files: ["src/ext/**/*.{js,svelte}"],
languageOptions: {
globals: {
...globals.browser,
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"name": "userscripts",
"private": true,
"type": "module",
"sideEffects": false,
"scripts": {
"dev": "vite",
"build": "npm run build:app && npm run build:ext",
"dev:ext-safari-mac": "SAFARI_PLATFORM=mac node scripts/dev-ext-safari.js",
"dev:ext-safari-ios": "SAFARI_PLATFORM=ios node scripts/dev-ext-safari.js",
"build:mac": "npm run build:app && npm run build:ext-safari-mac",
"build:ios": "npm run build:app && npm run build:ext-safari-ios",
"build:app": "node scripts/build-app.js",
"build:ext": "node scripts/build-ext-v4.js",
"build:ext-safari-mac": "SAFARI_PLATFORM=mac node scripts/build-ext-safari-15.js",
"build:ext-safari-ios": "SAFARI_PLATFORM=ios node scripts/build-ext-safari-15.js",
"build:ext-safari-mac-16.4": "SAFARI_PLATFORM=mac node scripts/build-ext-safari-16.4.js",
"build:ext-safari-ios-16.4": "SAFARI_PLATFORM=ios node scripts/build-ext-safari-16.4.js",
"lint:js": "eslint . && prettier --check . --plugin prettier-plugin-svelte",
"lint:css": "stylelint '**/*.{css,html,svelte}'",
"prettier": "prettier --write . --plugin prettier-plugin-svelte"
Expand Down
63 changes: 63 additions & 0 deletions public/ext/safari-15/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "_VERSION_",
"icons": {
"48": "images/icon-48.png",
"96": "images/icon-96.png",
"128": "images/icon-128.png",
"256": "images/icon-256.png",
"512": "images/icon-512.png"
},
"background": {
"scripts": ["dist/background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "dist/entry-ext-action-popup.html",
"default_icon": {
"16": "images/toolbar-icon-16.png",
"32": "images/toolbar-icon-32.png"
}
},
"content_scripts": [
{
"js": ["dist/content-scripts/userscripts.js"],
"matches": ["<all_urls>"],
"run_at": "document_start",
"all_frames": true
},
{
"js": ["dist/content-scripts/dot-user-js.js"],
"matches": [
"*://*/*.user.js",
"*://*/*.user.js?*",
"*://*/*.user.css",
"*://*/*.user.css?*"
],
"run_at": "document_start",
"all_frames": false
},
{
"js": ["dist/content-scripts/greasyfork.js"],
"matches": ["*://*.greasyfork.org/*"],
"run_at": "document_start",
"all_frames": false
}
],
"permissions": [
"<all_urls>",
"clipboardWrite",
"contextMenus",
"declarativeNetRequest",
"declarativeNetRequestWithHostAccess",
"menus",
"nativeMessaging",
"storage",
"tabs",
"unlimitedStorage",
"webNavigation"
]
}
1 change: 1 addition & 0 deletions public/ext/safari-16.4/images/128.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/ext/safari-16.4/images/action.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions public/ext/safari-16.4/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "_VERSION_",
"icons": {
"48": "images/128.svg",
"96": "images/128.svg",
"128": "images/128.svg",
"256": "images/128.svg",
"512": "images/128.svg"
},
"background": {
"scripts": ["dist/background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "dist/entry-ext-action-popup.html",
"default_icon": "images/action.svg"
},
"content_scripts": [
{
"js": ["dist/content-scripts/userscripts.js"],
"matches": ["<all_urls>"],
"run_at": "document_start",
"all_frames": true
}
],
"permissions": [
"<all_urls>",
"clipboardWrite",
"contextMenus",
"declarativeNetRequestWithHostAccess",
"menus",
"nativeMessaging",
"scripting",
"storage",
"tabs",
"unlimitedStorage",
"webNavigation"
],
"browser_specific_settings": {
"safari": {
"strict_min_version": "16.4"
}
}
}
Loading