Files
chrome-plugin/js/popup.js
xieyinlu ff550607ba init
2022-08-19 16:46:32 +08:00

48 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$(function () {
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
let url = tabs[0].url;
let favIconUrl = tabs[0].favIconUrl;
let title = tabs[0].title;
$('#url').val(url);
$('#title').val(title);
$('#icon').val(favIconUrl);
$("#icon-img").attr("src",favIconUrl);
// use `url` here inside the callback because it's asynchronous!
})
})
$("#sumbit").keyup(function(){
txt=$("input").val();
$.post("demo_ajax_gethint.asp",{suggest:txt},function(result){
$("span").html(result);
});
});
// $(function(){
// chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
// let url = tabs[0].url;
// $('#total').text(url);
// // use `url` here inside the callback because it's asynchronous!
// });
// //在第一次运行时如果总金额为0也不会留空而是有值显示
// chrome.storage.sync.get('total',function(budget){
// $('#total').text(budget.total);
// });
// $('#add').click(function(){
// //1、从浏览器获取存储的金额
// chrome.storage.sync.get('total',function(budget){
// var totalAmount = 0;
// if(budget.total){
// totalAmount = parseFloat(budget.total);
// }
// //2、将本次金额加到总金额中
// var amount = $('#amount').val();
// if(amount){
// totalAmount += parseFloat(amount);
// chrome.storage.sync.set({'total':totalAmount});
// }
// //3、更新显示ui
// $('#total').text(totalAmount);
// $('#amount').val('');
// })
// })
// })