用于浏览器的正则表达式链接切换器 [英] Regex Link Switcher for Browsers

查看:64
本文介绍了用于浏览器的正则表达式链接切换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一个我的想法的解决方案,下面是JS / Regex的片段,保存在书签链接中,当用户访问www.example.com并点击书签时, JS初始化并将链接切换到preview-www-example-com.dmzexample.com(内部预览环境)。最近我们的服务器/拱门已升级/更改,我不得不修改切换器。我想要做的是使用Chrome应用程序/扩展程序,当单击时打开一个对话框,您输入网址,然后选择一个预设复选框或实时复选框,然后单击一个提交按钮,将您带到所请求的网站。 br />
另外,对于新服务器,我必须添加一个依赖于网站的端口号,所以例如example.com:80 example2.com:8081这可以是应用程序中的另一个文本字段作为客户端会知道端口号。如果您有任何其他想法有助于实现我的目标,请告诉我。谢谢和快乐编码:)

I am trying to find an solution to an idea i have, below is a snippet of JS/Regex that is saved in a book mark link and when the user goes to www.example.com and clicks on the bookmark, the JS initializes and switches the link to preview-www-example-com.dmzexample.com(internal preview environment). Now recently our servers/arch have upgraded/changed, and im having to modify the switcher. What i want to do is use a chrome app/extension that when clicked on opens a dialog box you input the url and you select a prevew check box or a live check box and click a submit button that takes you to the requested site.
Also with the new servers i have to add a port number that is dependent on the site, so say example.com:80 example2.com:8081 this can be another text field in the app as the clients will know port number. If you have any other ideas that would help accomplish my goals please let me know. Thanks and Happy coding :)

javascript:(function(h){rd = (h.host.indexOf("preview-") == -1) ? "preview-" + h.host.replace(/\./g,"-") + ".dmzexample.com" + h.pathname : h.host.replace("preview-","").replace(".dmzexample.com","").replace(/-/g,".").replace(/.9/,"-9") + h.pathname; window.location = h.protocol + "//" + rd;})(location)

推荐答案

这篇关于用于浏览器的正则表达式链接切换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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