admin管理员组文章数量:1353584
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.
The first idea is to use a proxy (eg privoxy) and define a regular expression changing in html: </head>
to <script src=".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:
Go to page eg.: /
My index.php will download eg.: www.google 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.
Because I want to add only javascript, I thought that you can use iframes. But there is a restriction to the same domain.
Any ideas on how to do it? Maybe some tool? Something with cross-domain iframe?
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.
The first idea is to use a proxy (eg privoxy) and define a regular expression changing in html: </head>
to <script src="http://myserver./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:
Go to page eg.: http://myserver./
My index.php will download eg.: www.google. 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.
Because I want to add only javascript, I thought that you can use iframes. But there is a restriction to the same domain.
Any ideas on how to do it? Maybe some tool? Something with cross-domain iframe?
Share Improve this question edited Jan 28, 2011 at 9:18 Flexo - Save the data dump♦ 88.9k22 gold badges201 silver badges281 bronze badges asked Jan 28, 2011 at 9:12 fatmanfatman 1211 silver badge9 bronze badges 3- Don't use a proxy. That will not guarantee that the website will function normally. – Sasha Chedygov Commented Jan 28, 2011 at 9:38
- With a proper proxy (that does not require you to type some different address in the browser), it should work normally, no? – Christopher Creutzig Commented Jan 28, 2011 at 9:57
- I do not need that all links will works OK. I just want to see how this page will be looks like. The apache reverse proxy mode is what I need. – fatman Commented Jan 28, 2011 at 15:28
5 Answers
Reset to default 2You 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.
I'll throw Greasemonkey into the list of suggestions. Also note that FireBug allows you to run arbitrary JavaScript on a page, plus a lot more useful stuff for developing & debugging web apps.
(Although from your short description, I agree with awoodland that bookmarklets are probably the best solution.)
Bookmarklets let you do exactly this without any kludges.
if you are using Chrome, you can develop a simple extension and use the content scripts.
You can use the following project which is a node based proxy that can allow you to include any arbitrary JS or CSS in all pages
https://github./amitamb/plugin-proxy
I am the developer of the project.
本文标签: Add your javascript to any page (using proxy or something else)Stack Overflow
版权声明:本文标题:Add your javascript to any page (using proxy or something else) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743935306a2564554.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论