Javascript 当我在Java中单击Google搜索中的链接时,如何获取字符串的URL。谷歌扩展开发

Javascript 当我在Java中单击Google搜索中的链接时,如何获取字符串的URL。谷歌扩展开发,javascript,google-chrome-extension,Javascript,Google Chrome Extension,我第一次开发了护目镜伸展。我想在谷歌搜索中获取字符串的Url,并确定字符串(=selectedUrl)是一张图片、地图或文档,使用IF语句返回文件类型(=var fileType) 下面的代码位于content.js文件中 function urlSelected(e) { console.log('url select'); var selectedUrl = window.getSelection().toString(); //i think the getSelectio

我第一次开发了护目镜伸展。我想在谷歌搜索中获取字符串的Url,并确定
字符串(=selectedUrl)
是一张图片、地图或文档,使用IF语句返回
文件类型(=var fileType)

下面的代码位于content.js文件中

function urlSelected(e) {
    console.log('url select');
    var selectedUrl = window.getSelection().toString(); //i think the getSelection Should be changed
    var FileType = "File";
    console.log(selectedUrl);
    //using if sentence to 
    // FileType <- "Pic","Docu","Map" 
}

window.addEventListener('mouseup',urlSelected);
功能urlSelected(e){
log('url select');
var selectedUrl=window.getSelection().toString();//我认为应该更改getSelection
var FileType=“File”;
console.log(selectedUrl);
//使用if语句
//文件类型