代码拉取完成,页面将自动刷新
同步操作将从 browser-plug/chrome-website-ip 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
var appHoverTitle = chrome.i18n.getMessage('appHoverTitle');
function placeIPDiv() {
chrome.extension.sendMessage({
op: "getIp"
}, function (response) {
var ip = response.ip;
var dds = response.dds;
// inject 和 background 不互通 session, option 和 background 互通 session
// 根据ip 获取所在地址
chrome.extension.sendMessage({
op: "getAddr",
ip: ip
}, function (response) {
setTimeout(function () {
chromeShowTip(ip)
}, 1000);
});
});
}
function chromeShowTip(ip) {
chrome.extension.sendMessage({
op: "showTip"
}, function (response) {
var ext_enabled = response.ext_enabled;
var ipaddress = response.ipaddress;
if (ext_enabled == 1 || ext_enabled === undefined) {
$("body").append('<div title="' + appHoverTitle +
'" id="chrome-website-ip" >' + ipaddress + '<div id="chrome-website-ip-value">' + ip + "</div>" +
'</div>');
// 点击copy
$("#chrome-website-ip").on('click', function () {
copy("chrome-website-ip-value");
$("#chrome-website-ip-value").text("Copied!")
setTimeout(function () { $("#chrome-website-ip-value").text(ip) }, 1500);
});
chrome.storage.sync.get({
autohidden: true
}, function (items) {
if (items.autohidden) {
setTimeout(function () { document.getElementById("chrome-website-ip").style.display = "none"; }, 5000);
}
});
}
});
};
function copy(id) {
//Copy Content
var text = $("#" + id).text()
var $temp = $("<input>");
$("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
}
function hideIPDiv() {
document.getElementById('chrome-website-ip').remove();
}
$(document).ready(placeIPDiv);
window.lastKeyCode = 0;
window.lastHitTime = new Date();
$(document).keyup(function (e) {
// If the 'Esc' key is pressed before the HTML (yes, HTML only) could
// fully load, show the IP <div> as $(document).ready() doesn't execute.
if (document.getElementById('chrome-website-ip') === null && e.keyCode ==
27) {
placeIPDiv();
} else {
now = new Date();
timeDiff = now - window.lastHitTime;
window.lastHitTime = now;
// 双击`F2`弹出可复制的`ip`
/* if (e.keyCode == 113 && window.lastKeyCode == 113 && // two "F2" keystrokes
timeDiff < 900) { // within 900ms
window.lastKeyCode = 0;
window.prompt('IP of "' + window.location.host + '":',
document.getElementById('chrome-website-ip').innerText);
}*/
// 双击`F4` 去项目主页
if (e.keyCode == 115 && window.lastKeyCode == 115 && timeDiff < 900) {
window.lastKeyCode = 0;
window.open(
"http://git.oschina.net/surprise/Chrome.Website.Ip#git-readme");
}
// 再次按ESC隐藏
if (e.keyCode == 27) {
hideIPDiv();
}
}
window.lastKeyCode = e.keyCode;
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。