问题
Note: The Code I've written isn't polished, it's just for prototyping, so please excuse me if I have any bad practices and correct me if I do! Thank you.
How can I disable or remove download button in Universign signing form?
I have the form embedded in an iframe like this.
<iframe src="https://app.universign.com/sig/sign/(form id goes here)" sandbox='allow-scripts allow-same-origin
I've written a script to manipulate and use cors-anywhere API to GET all the necessary files such as css files, scripts etc.
And I created the iframe on my own page to bypass CORS.
The issue is that they're using WebPack and Angular if I'm not wrong and they are building the page with JavaScript on the go. While they're building it they assign the baseUrl which is http://app.universign.com/sig/ and I tried to add the CORS proxy (cors-anywhere) before the baseUrl on every function, but it still doesn't seem to work. They are fetching json objects to define some configurations, via POST request.
How can I bypass this and make this iframe editable, I've stumbled across this wall and I need some thoughts to get over it. Any help is appreciated.
Note that I succeeded on fetching the css and js, putting it onto iframe. The only issue left is the JavaScript side, where it pulls the configurations.
The Code I've written:
<html>
<head>
<title></title>
<style>
* {
margin: 0 padding:0
}
body {
margin: 0;
padding: 0;
text-align: center
}
#hold_my_iframe {
padding: 0px;
margin: 0 auto;
width: 100%;
height: 100%
}
</style>
</head>
<body>
<table border=0 cellspacing=0 cellpadding=0 id="hold_my_iframe"
sandbox="allow-forms allow-popups allow-scripts allow-same-origin">
<iframe id="frame" src="javascript:void(0)" style="height: 80%; width: 60%;"></iframe>
</table>
<!-- This paragraph is used to display the source code of their main.js, which has the beginUrl variable -->
<p id="paragraph"></p>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>
(function ($) {
function getIndicesOf(searchStr, str, caseSensitive) {
var searchStrLen = searchStr.length;
if (searchStrLen == 0) {
return [];
}
var startIndex = 0, index, indices = [];
if (!caseSensitive) {
str = str.toLowerCase();
searchStr = searchStr.toLowerCase();
}
while ((index = str.indexOf(searchStr, startIndex)) > -1) {
indices.push(index);
startIndex = index + searchStrLen;
}
return indices;
}
var frame = $("#frame");
var htmlDoc;
var htmlWrapper = $(document.createElement("html"))[0];
var url = "https://app.universign.com/sig/";
var cssLocations = [];
var jsLocations = [];
$.ajax({
url: "http://cors-anywhere.herokuapp.com/https://app.universign.com/sig/sign/3b362bc3-5aba-40bd-96cd-6c2e1254410b",
method: "GET",
success: function (data) {
htmlDoc = $(data);
console.log(htmlDoc);
htmlDoc.each(function (index, el) {
if ($(el).is("base")) {
// Setting up the base URL, this is used by href and src attributes to fetch images etc.
// It basically specifies where the data should be pulled from
$(el).attr("href", "https://app.universign.com/sig/");
}
if ($(el).is("link")) {
var attribute = $(el).attr("href");
if (attribute !== "assets/favicon.ico" && attribute !== undefined && attribute !== null) {
cssLocations.push(attribute);
}
} else if ($(el).is("script")) {
var attribute = $(el).attr("src");
if (attribute !== undefined && attribute !== null) {
jsLocations.push(attribute);
}
}
});
},
async: false,
});
cssLocations.reverse();
jsLocations.reverse();
console.log(htmlDoc);
cssLocations.forEach(function (el) {
console.log(el)
$.ajax(
{
url: "https://cors-anywhere.herokuapp.com/https://app.universign.com/sig/" + el,
method: "GET",
success: function (data) {
htmlDoc.splice(11, 0, $.parseHTML("<style>" + data + "</style>")[0]);
console.log(htmlDoc);
},
async: false,
});
});
var shouldI = true;
jsLocations.forEach(function (el) {
console.log(el);
$.ajax(
{
url: "https://cors-anywhere.herokuapp.com/https://app.universign.com/sig/" + el,
method: "GET",
success: function (data) {
var indices = getIndicesOf("baseUrl +", data, true);
console.log(indices);
indices.forEach(function(el){
if(shouldI){
var endData = data.slice(0, indices[0]) + "'https://cors-anywhere.herokuapp.com/' +" + data.slice(indices[0], data.length);
$("#paragraph").html(endData);
shouldI = false;
data = endData;
}
});
htmlDoc.splice(19, 0, $("<script>" + data + "</" + "script>")[0]);
console.log(htmlDoc)
},
async: false,
})
});
htmlDoc.each(function (index, el) {
if (el !== null && el !== undefined) {
htmlWrapper.appendChild(el);
}
});
frame.attr("srcdoc", htmlWrapper.innerHTML);
})(jQuery)
</script>
</body>
</html>
You can find their source code here: Source
来源:https://stackoverflow.com/questions/60187615/universign-disabling-pdf-download