将您的JavaScript添加到任何页面(使用代理或其他方式) [英] Add your javascript to any page (using proxy or something else)

查看:63
本文介绍了将您的JavaScript添加到任何页面(使用代理或其他方式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是能够看到附有JavaScript的任何网站的外观。我想创建一个在任何网站上都可以使用的选择器之类的东西。

What I want to do is be able to see how it will look any website with my javascript attached . I want to create something like selectorgadget working on any website.

第一个想法是使用代理(例如privoxy)并定义一个在html中更改的正则表达式:< / head> < script src = http://myserver.com/my_javascript.js>< / script>< / head> 。它可以工作,但是在这种情况下,我需要在浏览器中设置代理。

The first idea is to use a proxy (eg privoxy) and define a regular expression changing in html: </head> to <script src="http://myserver.com/my_javascript.js"></script></head>. It works, but in such case, I need to set proxy in my browser. And it is not cool because It visible only for me.

另一个想法是编写一个网站,将在后台下载页面并显示它。它将如何工作:

Another idea is to write a website that will download page under the hood and show it. How it will work:


  1. 转到页面,例如: http://myserver.com/

我的index.php将下载,例如:www.google.com使用http客户端或curl替换页面源(在< / head> 之前添加我的< script> )并返回页面给用户。可以,但是页面包含相对图像时,我看不到它。重写图像src和其他脚本src并不是那么简单。

My index.php will download eg.: www.google.com using http client or curl, replace page source (add my <script> before </head>) and return page to user. It works, but when page contains relative images I'm not able to see it. Rewriting image src, and other script src is not so simple.

因为我只想添加JavaScript,所以我认为您可以使用iframe但是对同一个域有一个限制。

Because I want to add only javascript, I thought that you can use iframes. But there is a restriction to the same domain.

有什么想法可以做到吗?也许一些工具?可以使用跨域iframe吗?

Any ideas on how to do it? Maybe some tool? Something with cross-domain iframe?

推荐答案

您可以将Apache Web服务器配置为以反向代理模式工作,并使用第一种方法。因此,它的工作方式与您的第二种情况非常相似,但是所有替换的Apache服务器都可以为您完成。

You can configure Apache web server to work in reverse proxy mode and use your first approach. Hence it will work very similar to your second case, but all replacement Apache server will do for you.

这篇关于将您的JavaScript添加到任何页面(使用代理或其他方式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆