Skip to content

Instantly share code, notes, and snippets.

@avin
Last active March 12, 2023 10:02
Show Gist options
  • Save avin/ac7afcaafa40c2671e2c595cdcf69449 to your computer and use it in GitHub Desktop.
Save avin/ac7afcaafa40c2671e2c595cdcf69449 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name SuperAjax for AppLinks
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Allow to do cross-domain AJAX requests
// @author You
// @run-at document-start
// @connect *
// @match https://localhost:5173/*
// @match https://web.rbsdev.com/front-utils/app-links/*
// @icon https://web.rbsdev.com/front-utils/app-links/favicon.svg
// @grant GM.xmlHttpRequest
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
unsafeWindow._superAjax = (url) => {
if(!(url.endsWith('/template.json') || url.endsWith('/version.txt'))){
console.log(url);
return Promise.reject('not allowed url')
}
return new Promise((resolve, reject) => {
GM.xmlHttpRequest({
method: "GET",
url,
onload: resolve,
onerror: reject,
});
})
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment