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
185 additions
and
21 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
16 changes: 16 additions & 0 deletions
16
packages/backend/migration/1732244400000-tmsServerCustomCss.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,16 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export class TmsServerCustomCss1732244400000 { | ||
name = 'TmsServerCustomCss1732244400000'; | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" ADD "tmsServerCustomCss" character varying(8192)`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "tmsServerCustomCss"`); | ||
} | ||
} |
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
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,60 @@ | ||
/* | ||
* 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 !params.has('disableCustomCss') && !params.has('disablecustomcss'); | ||
})(); | ||
|
||
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 = `${configUrl}/?disableCustomCss`; | ||
console.warn(`Custom CSS has been applied. To temporarily disable it, please visit ${url}.`); | ||
console.warn(`カスタムCSSが適用されました。一時的に無効にするには ${url} にアクセスします。`); | ||
} | ||
} |
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.