Skip to content

Commit

Permalink
add MOD: Add hostname to title
Browse files Browse the repository at this point in the history
  • Loading branch information
Cp0204 committed May 1, 2024
1 parent 2d86489 commit 893a8ca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ In addition, you can access the files in the `/DATA/AppData/casamod/icon` direct

| Name | Description | Author |
| ---- | ----------- | ------ |
| add-hostname-to-title | Add hostname to title ➕ | Cp0204 |
| small-app-icon | Smaller app icons 🤏 | Cp0204 |
| allow-modify-image | Allow modify image settings ✏️ | Cp0204 |
| add-widget-quotable | Add Quotable widget 💬 | Cp0204 |
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

| 名称 | 功能描述 | 作者 |
| --- | -------- | ---- |
| add-hostname-to-title | 添加主机名到网页标题 ➕ | Cp0204 |
| small-app-icon | 更小的应用图标 🤏 | Cp0204 |
| allow-modify-image | 允许编辑镜像设置 ✏️ | Cp0204 |
| add-widget-quotable | 增加一言小部件 💬 | Cp0204 |
Expand Down
25 changes: 25 additions & 0 deletions app/mod/add-hostname-to-title/mod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// name: add-hostname-to-title
// author: Cp0204
// date: 2024-05-01
// description: 添加访问地址到网页标题,用以区分多个主机;因为没有后端获取主机名,所以默认用访问地址;你也可以直接修改本 js 用自定义字符串。
// description: Add the access address to the page title to differentiate between multiple hosts; since there is no backend to get the hostname, the default is the access address; you can also modify this js directly to use a custom string.

(function () {
// 自定义字符
// Custom Strings
let additionalTitle = "";

if (additionalTitle == "") {
const hostname = window.location.hostname;
const port = window.location.port;
if (hostname) {
additionalTitle += hostname;
if (port) {
additionalTitle += ":" + port;
}
}
}
if (additionalTitle != "") {
document.title = document.title + " - " + additionalTitle;
}
})();

0 comments on commit 893a8ca

Please sign in to comment.