开发者

How can I check if an external link contains playable media before opening in new tab

I would like to check if an external link cont开发者_JAVA技巧ains playable media before opening the link in a new tab. I am attempting to do this in an if else format so that I can modify the link if it does not contain playable media. I am struggling to figure out how to check for this if both links end in .mp4 in the URL. Essentially one link gets an XML error and the other does not, and I am trying to account for these differences and dynamically adjust the link before opening it. Any advice would be helpful. Ive also just tried to check for strings on the new page to see if there is an XML error, but the script stops as soon as a new tab is opened with window.open, and chrome.tabs.create doesn't seem to work. Im new to javascript

`

//var win = window.open(modifiedLink, '_blank').focus();
chrome.tabs.create({
    url: modifiedLink,
    selected: true,
  })

var checkForErrors = document.querySelector("body > div.header > span").innerHTML;

if (checkForErrors.includes("This XML file does not appear to have any style")) {
    modifiedLink = modifiedLink.replace('/ask_video/', '/encoded/')
    window.open(modifiedLink, '_blank').focus();
}

`

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜