需要修改的文件:
splunk/share/splunk/search_mrsparkle/exposed/js/i18n.js
在文件最下面添加代码:
// waiting for the element
function wait_for_element(selector, callback) {
element = document.querySelector(selector);
if (element) {
callback();
} else {
setTimeout(() => {
wait_for_element(selector, callback);
}, 100);
}
}
// change splunk logo
wait_for_element("span[data-role='logo']", () => {
// delete the splunk logo
del_splunk = document.querySelector("i[data-icon='splunk']");
del_gt = document.querySelector("span[data-role='gt']");
del_logo = document.querySelector("span[data-role='logo']");
del_logo.parentNode.removeChild(del_logo);
del_gt.parentNode.removeChild(del_gt);
del_splunk.parentNode.removeChild(del_splunk);
// add new logo img element
new_img= document.createElement("img");
new_img.src = "your img path";
// new_img.width="140";
// new_img.height="30"; // 图片高度为30px能够最佳显示
document.querySelectorAll("a[title='splunk > listen to your data']")[0].appendChild(new_img);
});
曾经使用过如下代码:
// change splunk logo
window.addEventListener('load', function() {
del_splunk = document.querySelector("i[data-icon='splunk']");
del_gt = document.querySelector("span[data-role='gt']");
del_logo = document.querySelector("span[data-role='logo']");
del_logo.parentNode.removeChild(del_logo);
del_gt.parentNode.removeChild(del_gt);
del_splunk.parentNode.removeChild(del_splunk);
new_img= document.createElement("img");
new_img.src = "your img path";
// new_img.width="200";
// new_img.height="30";
document.querySelectorAll("a[title='splunk > listen to your data']")[0].appendChild(new_img);
// });
测试中发现,当Splunk进入某些app后,失效。(无法找到element而出现undefined)
虽不使用,但留作记录。