Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'development'

  • Loading branch information...
commit 3ab097c579c62b2ce88a11e8d9d0feb30c1d2cf3 2 parents cbc5947 + b2b2b15
Amit Ambardekar authored
Showing with 54 additions and 22 deletions.
  1. +54 −22 public/screenjs-proxy.js
76 public/screenjs-proxy.js
View
@@ -37,7 +37,7 @@ var translateTargetHostToRequestHost = function(targetHost, targetProtocol){
}
if ( targetProtocol ) {
- if ( targetProtocol == "https:" ) {
+ if ( targetProtocol == "https:" && targetHost.indexOf("https.") != 0 ) {
targetHost = "https" + "." + targetHost;
}
// else http
@@ -48,7 +48,7 @@ var translateTargetHostToRequestHost = function(targetHost, targetProtocol){
// targetUrl - It need not be absolute
var translateTargetUrlToRequestUrl = function(targetUrl){
- var requestUri = document.createElement("a");
+ var requestUri = document._createElement("a");
requestUri.href = targetUrl;
if ( requestUri.protocol != "https:" && requestUri.protocol != "http:" ) {
@@ -110,7 +110,7 @@ document.addEventListener("click",function(event){
document.addEventListener("submit",function(event){
var formNode = event.target;
- var urlParts = document.createElement("a");
+ var urlParts = document._createElement("a");
urlParts.href = formNode.action;
if ( urlParts.protocol == "http:" || urlParts.protocol == "https:" ) {
// Checking if string ends with proxy URL
@@ -147,25 +147,57 @@ HTMLFormElement.prototype.submit = function() {
// i.e. issue related to workflowy's handling of page URL change
// but it could also be used to handle issue on blekko.com where
// dynamically loaded script gets wrong address
-// document._createElement = document.createElement;
-
-// document.createElement = function(name){
-// var retElem = document._createElement.apply(document, arguments);
-// if ( name.toLowerCase() == "a" ) {
-// // alert("Handle link");
-// Object.defineProperty(retElem, "href", {
-// get: function(){
-// return windowLocation;
-// },
-// set: function(val){
-// windowLocation = translateTargetUrlToRequestUrl(val);
-// window.location = windowLocation
-// //document.domain="www.rediff.com";
-// }
-// });
-// }
-// return retElem
-// };
+
+document._createElement = document.createElement;
+
+document.createElement = function(name){
+ var retElem = document._createElement.apply(document, arguments);
+ if ( name.toLowerCase() == "a" ) {
+
+ retElem._setAttribute = retElem.setAttribute;
+
+ retElem.setAttribute = function(key, val){
+ if ( key.toLowerCase() == "href" ){
+ val = translateTargetUrlToRequestUrl(val)
+ }
+ retElem._setAttribute(key, val);
+ };
+
+ Object.defineProperty(retElem, "href", {
+ get: function(){
+ return retElem.getAttribute("href");
+ },
+ set: function(val){
+ retElem._setAttribute("href", translateTargetUrlToRequestUrl(val));
+ }
+ });
+ }
+
+ if ( name.toLowerCase() == "script" ) {
+ var src=retElem.src;
+
+ retElem._setAttribute = retElem.setAttribute;
+
+ retElem.setAttribute = function(key, val){
+ if ( key.toLowerCase() == "src" ){
+ val = translateTargetUrlToRequestUrl(val)
+ }
+ retElem._setAttribute(key, val);
+ };
+
+ Object.defineProperty(retElem, "src", {
+ get: function(){
+ //"script.js"
+ return retElem.getAttribute("src");
+ },
+ set:function(val){
+ retElem._setAttribute("src", translateTargetUrlToRequestUrl(val));
+ }
+ });
+ }
+
+ return retElem;
+};
// 3. window.location change from script and similar methods
Please sign in to comment.
Something went wrong with that request. Please try again.