Skip to content

Instantly share code, notes, and snippets.

@muedsa
Created September 7, 2022 05:25
Show Gist options
  • Save muedsa/8eb2a0974f4361c5337ee198aa733c32 to your computer and use it in GitHub Desktop.
Save muedsa/8eb2a0974f4361c5337ee198aa733c32 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name grafana loki query remove bom
// @namespace https://www.muedsa.com
// @version 0.1
// @description try to take over the world!
// @author MUEDSA
// @match https://test-grafana.fskops.com/explore?*
// @run-at document-start
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
const originFetch = fetch;
unsafeWindow.fetch = (...args) => {
if(args[0].indexOf('api/datasources/proxy/1/loki/api/v1/query_range') >= 0){
let replacedPath = args[0].replaceAll(/%EF|%BB|%BF/g, '');
args[0] = replacedPath;
}
return originFetch(...args);
}
console.log('grafana loki query remove bom load success');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment