forked from misskey-dev/misskey
-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
17 changed files
with
187 additions
and
15 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
17 changes: 17 additions & 0 deletions
17
packages/backend/migration/1739404800000-TaiymeServerCustomCss.js
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,17 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
1739442551466 | ||
export class TaiymeServerCustomCss1739404800000 { | ||
name = 'TaiymeServerCustomCss1739404800000'; | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" ADD "taiymeServerCustomCss" character varying(8192)`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "taiymeServerCustomCss"`); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { url as configUrl } from '@@/js/config.js'; | ||
|
||
const availableCustomCss = (() => { | ||
const params = new URLSearchParams(window.location.search); | ||
return ['true', 'yes', 'on', 't', '1'].includes(params.get('customcss')?.toLowerCase() ?? 'true'); | ||
})(); | ||
|
||
export function applyCustomCss({ serverCustomCss, userCustomCss }: { | ||
readonly serverCustomCss?: string | null; | ||
readonly userCustomCss?: string | null; | ||
}) { | ||
if (!availableCustomCss) return; | ||
if (serverCustomCss === undefined && userCustomCss === undefined) return; | ||
|
||
let serverStyleTag = document.getElementById('server_custom_css'); | ||
if (serverCustomCss !== undefined) { | ||
if (serverCustomCss === null || serverCustomCss === '') { | ||
serverStyleTag?.remove(); | ||
serverStyleTag = null; | ||
} else { | ||
if (serverStyleTag == null) { | ||
serverStyleTag = document.createElement('style'); | ||
serverStyleTag.id = 'server_custom_css'; | ||
} | ||
serverStyleTag.textContent = serverCustomCss; | ||
} | ||
} | ||
|
||
let userStyleTag = document.getElementById('user_custom_css'); | ||
if (userCustomCss !== undefined) { | ||
if (userCustomCss === null || userCustomCss === '') { | ||
userStyleTag?.remove(); | ||
userStyleTag = null; | ||
} else { | ||
if (userStyleTag == null) { | ||
userStyleTag = document.createElement('style'); | ||
userStyleTag.id = 'user_custom_css'; | ||
} | ||
userStyleTag.textContent = userCustomCss; | ||
} | ||
} | ||
|
||
if (serverStyleTag != null) { | ||
document.head.appendChild(serverStyleTag); | ||
} | ||
if (userStyleTag != null) { | ||
document.head.appendChild(userStyleTag); | ||
} | ||
|
||
if (serverStyleTag != null || userStyleTag != null) { | ||
const url = new URL(configUrl); | ||
url.searchParams.set('customcss', 'false'); | ||
console.log(`Custom CSS has been applied. To temporarily disable it, please visit ${url.href}.`); | ||
console.log(`カスタムCSSが適用されました。一時的に無効にするには ${url.href} にアクセスします。`); | ||
} | ||
} |
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
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
Oops, something went wrong.