0
我的網站上安裝了Google自定義搜索引擎。我想修改搜索結果。我知道它可能會傷害ToS。使用自定義代碼修改Google自定義搜索結果
所以,首先,我想從每個搜索結果中刪除一些字符串。下面是我前面寫的函數:
<script type="text/javascript">
setInterval("pakeisti()",100)
function pakeisti()
{
elem = document.getElementById("searchas");
y = elem.getElementsByTagName("div");
for (i=0; i< y.length; i++)
{
str = y[i].className;
if (str.search("gs-title") != 0) {
var newHTML = y[i].innerHtml;
newHTML = newHTML.replace('STRING - ',' k');
newHTML = newHTML.replace('<a','<p');
newHTML = newHTML.replace('</a>','</p>');
y[i].innerHtml = newHTML; }
}
}
</script>
早些時候,這個腳本工作,但現在它給我的錯誤: Uncaught TypeError: Cannot call method 'replace' of undefined