结合Bookmarklets在HTTP和HTTPS之间创建切换? [英] Combining Bookmarklets to create a toggle between HTTP and HTTPS?

查看:132
本文介绍了结合Bookmarklets在HTTP和HTTPS之间创建切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过在这里搜索,我现在有两个bookmarklet,从/切换到HTTP / HTTPS: -

By searching here, I now have two bookmarklets, which switch from/to HTTP/HTTPS :-

javascript:location=location.href.replace(/http:/g,"https:")

并且.. 。

javascript:location=location.href.replace(/https:/g,"http:")

但是,有没有办法将它们组合成一个小书签,它将根据一个书签切换到另一个小书签。到目前为止加载的那个?

But is there a way, please, to combine them into a single bookmarklet, which will toggle from one to the other according to whichever is presently loaded?

推荐答案

这个帖子有点旧,但我还没有找到更好的答案。

This thread is a little old, but I haven't found a better answer anywhere else.

javascript:((function(){window.location = location.href.replace(/ ^ http / i,https)。替换(/ ^ http\w {2,} / i,http);})())

完全成型应该可以在任何浏览器中使用的bookmarklet代码。

is fully formed bookmarklet code that should work in any browser.

这篇关于结合Bookmarklets在HTTP和HTTPS之间创建切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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