Exemple #1
0
        public void FilterAndInject(Session oSession)
        {
            Debug.Log("FilterAndInject: MatchRule check!" + oSession.fullUrl);
            // response content type is text/html
            if (bGlobalEnabled && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html"))
            {
                Debug.Log("FilterAndInject: MatchRule check!");
                // request url is match the user's config rules
                if(this.MatchRule(oSession))
                {
                    oSession.utilDecodeResponse();
                    oSession.utilReplaceOnceInResponse(@"<head>", @"<head><script>" + sScriptText + "</script>", false);

                    // script tag add crossorigin 
                    oSession.utilReplaceInResponse(@"<script", @"<script crossorigin ");

                    oSession.oResponse.headers["Cache-Control"] = "no-cache";
                    oSession.oResponse.headers["Content-Length"] = oSession.responseBodyBytes.Length.ToString();
                }
            }

           // javascript request, add cross domain header
           if (oSession.fullUrl.Contains(".js"))
           {
               if (oSession.oResponse.headers["Access-Control-Allow-Origin"] == "")
               {
                   oSession.oResponse.headers["Access-Control-Allow-Origin"] = "*";
               }
           }
        }
        static void ForceOverrideStylesheet(Session rpSession)
        {
            rpSession.utilDecodeResponse();
            rpSession.utilReplaceInResponse("</head>", @"<style type=""text/css"">
html { touch-action: none }

body {
    margin: 0;
    overflow: hidden;
}

#ntg-recommend, #dmm-ntgnavi-renew { display: none !important; }

#game_frame {
    position: fixed;
    left: 50%;
    top: -16px;
    margin-left: -450px;
    z-index: 255;
}
</style></head>");
        }
        public void AutoTamperResponseBefore(Session oSession)
        {
            if (!IsEnabled || !EnableAutoReload)
            {
                return;
            }

            var fullString = oSession.fullUrl.ToLower();

            foreach (var profile in _enabledProfiles)
            {
                if (fullString.Contains(profile.RemoteUrl.ToLower()))
                {
                    oSession.utilDecodeResponse();
                    bool replaced = oSession.utilReplaceInResponse("</body>", string.Format(
                        @"<script type='text/javascript'>window.__IMPOSTER = {{ profileId: '{0}' }};</script>
                          <script type='text/javascript' src='imposter.js'></script>
                          </body>", profile.ProfileId));

                    break;
                }
            }
        }