-
Notifications
You must be signed in to change notification settings - Fork 4
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
3 changed files
with
29 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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 = ""; | ||
|
||
const currentTitle = document.title; | ||
const hostname = window.location.hostname; | ||
const port = window.location.port; | ||
|
||
if (additionalTitle == "") { | ||
if (hostname) { | ||
additionalTitle += hostname; | ||
if (port) { | ||
additionalTitle += ":" + port; | ||
} | ||
} | ||
} | ||
if (additionalTitle != "") { | ||
document.title = currentTitle + " - " + additionalTitle; | ||
} | ||
})(); |