var name = "cnyist"; var repository = "blog"; if(document.domain != 'localhost'){ if(document.getElementById("post")){ for (var key indocument.getElementById("article-container").getElementsByTagName('img')){ if (isNaN(key)){ break; } document.getElementById("article-container").getElementsByTagName('img')[key].src = document.getElementById("article-container").getElementsByTagName('img')[key].src.replace(document.domain,"cdn.jsdelivr.net/gh/" + name + "/" + repository) } } }
Matery
1 2 3 4 5 6 7 8 9 10
var name = "cnyist"; var repository = "blog"; if(document.domain != 'localhost'){ for (var key indocument.getElementById("articleContent").getElementsByTagName('img')){ if (isNaN(key)){ break; } document.getElementById("articleContent").getElementsByTagName('img')[key].src = document.getElementById("articleContent").getElementsByTagName('img')[key].src.replace(document.domain,"cdn.jsdelivr.net/gh/" + name + "/" + repository) } }
Icarus
1 2 3 4 5 6 7 8 9 10 11 12
var name = "cnyist"; var repository = "blog"; if(document.domain != 'localhost'){ if(document.getElementsByClassName("post-copyright")[0] || document.URL == "https://" + document.domain + '/'){ for (var key indocument.getElementsByClassName("card-content article")[0].getElementsByTagName('img')){ if (isNaN(key)){ break; } document.getElementsByClassName("card-content article")[0].getElementsByTagName('img')[key].src = document.getElementsByClassName("card-content article")[0].getElementsByTagName('img')[key].src.replace(document.domain,"cdn.jsdelivr.net/gh/" + name + "/" + repository) } } }
Next
1 2 3 4 5 6 7 8 9 10
var name = "cnyist"; var repository = "blog"; if(document.domain != 'localhost'){ for (var key indocument.getElementById("posts").getElementsByTagName('img')){ if (isNaN(key)){ break; } document.getElementById("posts").getElementsByTagName('img')[key].src = document.getElementById("posts").getElementsByTagName('img')[key].src.replace(document.domain,"cdn.jsdelivr.net/gh/" + name + "/" + repository) } }
如果以上 js 代码没有你的主题, 你又不好意思留言 (或者不想等太久) , 那么就需要你自己更改以上 js 代码.以 Butterfly 主题的 js 代码为例, 将 article-container 改成你自己主题的文章内容的 Html 标签 id , 而 post 改成你自己主题 Post 文章特有的 id (就是说这个 id page 是没有的, 用于判断该页是 Post 还是 Page) .