zoukankan      html  css  js  c++  java
  • Chrome插件开发笔记

    使用 XMLHttpRequest来抓取盗版小说网站里面的内容,但是注意需要在manifest.json文件中设置permission

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://www.biqukan.com/1_1207/", true);
    xhr.onreadystatechange = function() {

    if (xhr.readyState == 4) {
    // var resp = eval("(" + xhr.responseText + ")");
    }
    }
    xhr.send();

    本来还以为纯JS跨域问题应该无法跨越,没想到chrome插件中跨域请求这么方便....

    popup.html中不不能使用inline javascript代码,这个比较坑,必须在popup.js里面用addEventListener()

    onclick=XXX()是没用的,点击事件是不会生效的

    暂时只用到了popup.html和popup.js

    background.html和background.js还没有研究过

    不过一旦js文件作为content_script在manifest.json中被声明了,加载网页之后就会被自动执行,而popup.js只会在点击插件图标之后才会被popup.html调用

    最后弄了个抓取小说最新更新的插件( ╯□╰ )然而这个小说网站一到晚上就无法访问(尴尬) 换个盗版网站的话解析html的代码又得改。。。凑和着用吧先。

  • 相关阅读:
    0593. Valid Square (M)
    0832. Flipping an Image (E)
    1026. Maximum Difference Between Node and Ancestor (M)
    0563. Binary Tree Tilt (E)
    0445. Add Two Numbers II (M)
    1283. Find the Smallest Divisor Given a Threshold (M)
    C Primer Plus note9
    C Primer Plus note8
    C Primer Plus note7
    C Primer Plus note6
  • 原文地址:https://www.cnblogs.com/fanninnypeom/p/5898503.html
Copyright © 2011-2022 走看看