script.sh 1.3 KB

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. # 创建emby-crx目录并下载所需文件
  3. rm -rf emby-crx
  4. mkdir -p emby-crx
  5. wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/css/style.css -P emby-crx/
  6. wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/common-utils.js -P emby-crx/
  7. wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/jquery-3.6.0.min.js -P emby-crx/
  8. wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/static/js/md5.min.js -P emby-crx/
  9. wget https://raw.githubusercontent.com/Nolovenodie/emby-crx/master/content/main.js -P emby-crx/
  10. # 读取index.html文件内容
  11. content=$(cat index.html)
  12. # 检查index.html是否包含emby-crx
  13. if [[ "$content" == *"emby-crx"* ]]; then
  14. echo "Index.html already contains emby-crx, skipping insertion."
  15. else
  16. # 定义要插入的代码
  17. code='<link rel="stylesheet" id="theme-css" href="emby-crx/style.css" type="text/css" media="all" />\n<script src="emby-crx/common-utils.js"></script>\n<script src="emby-crx/jquery-3.6.0.min.js"></script>\n<script src="emby-crx/md5.min.js"></script>\n<script src="emby-crx/main.js"></script>'
  18. # 在</head>之前插入代码
  19. new_content=$(echo -e "${content/<\/head>/$code<\/head>}")
  20. # 将新内容写入index.html文件
  21. echo -e "$new_content" > index.html
  22. fi