我想编写一个Firefox Webextension,它在选定的坐标上执行链接。
它应将-34.802551,-58.438485(x,y)之类的坐标转换为链接
http://127.0.0.1:8111/load_and_zoom?left=(x-0.1)&right=(x+0.1)&top=(y-0.1)&bottom=(x+0.1)
这是JOSM遥控器。
我找到了以下代码段:
<form action="login.php" method="POST" id="Login">
<div class="form-group">
<input class="form-control" placeholder="email id" id="email" name="email" type="email">
</div>
<div class="form-group">
<input class="form-control" name="password" id="password" placeholder="email password" type="password">
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
如何适应?
答案 0 :(得分:0)
您可能需要此:
browser.menus.onClicked.addListener((info, tab) => {
let selection = info.selectionText;
let x = selection.split(",")[0];
let y = selection.split(",")[1];
browser.tabs.create({
url: `http://127.0.0.1:8111/load_and_zoom?left=(${x}-0.1)&right=(${x}+0.1)&top=(${y}-0.1)&bottom=(${x}+0.1)`;
});
});
它将使用您选择的坐标打开新标签。