{ "name": "UniConvertor", "version": "1.0", "manifest_version": 2, "devtools_page": "devtools.html" }
<!doctype html> <html> <head> <script src="jquery.js"></script> <script src="test.js"></script> </head> <body> </body> </html>
var log = function(obj) { var str = JSON.stringify( obj ); chrome.devtools.inspectedWindow.eval('console.log(' + str + ');'); } //Listener, console/sources - , chrome.devtools.inspectedWindow.onResourceContentCommitted.addListener(function(resource, content) { var s = resource.url.split('/'); var protocol = resource.url.indexOf("https:")!=-1?"https://":"http://"; var url = protocol + (s[2] || s[0]) + "/Updater"; // , - ... log(url); jQuery.ajax({ type: "POST", url: url, data: {'url':resource.url, 'data':content}, success: function(data) { log(data); } }); //... . resource.url - , content - });
public class UpdaterController : Controller { // // GET: /Updater/ public ActionResult Index() { return null; //View , } [HttpPost] public ActionResult Index(string url, string data) { var path = url.Replace(Request.Url.GetLeftPart(UriPartial.Authority), ""); // path = Server.MapPath(path); // var exists = System.IO.File.Exists(path); if(exists) //, System.IO.File.WriteAllText(path, data); //? - . return null; } }
Source: https://habr.com/ru/post/243271/
All Articles