QQ圍棋棋譜

騰訊圍棋分享出來的鏈接:

https://huanle.qq.com/act/a20170110wq/index-photo.html?type=1&chess=0200002200110000000202002022112100000000220202212211220000220000022211110200020002002022221120002202020221111120000012222221101012000001111121012022120000012221111200012000200011102200201200002112001002000100000000201211001220000002200022110011000002111002000200020000200001001120112000011000002020012000000000102202201200000000012211121000000000000000001000000

其實棋譜就在這一串書數字裏,懶得去解析,可以直接分析網頁源代碼。

通過源代碼就能看出每顆棋子的位置。

用Tampermonkey寫一個腳本,就可以得到對應的棋譜了。

// ==UserScript==
// @name         騰訊圍棋轉譜
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://huanle.qq.com/act/*
// @grant        none
// @require    http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==

(function() {
    'use strict';
    setTimeout(function () { load(); }, 2000);
    $(".comment_title1").append("<textarea id='qp' style='width:100%;height:100px'>棋譜生成中...</textarea>");
    function load() {
        var arr = "ABCEDFGHIJKLMNOPQRS";
        var res = "(";
        $("#gameView div").each(function () {
            var left = $(this).css("left").replace("px", "") - 19;
            var top = $(this).css("top").replace("px", "") - 19;
            var x = arr[left / 38].toLowerCase();
            var y = arr[top / 38].toLowerCase();
            var c = $(this).attr("class") == "chessBlack" ? "B" : "W";
            res += (c + "[" + x + y + "]") + ";"
        });
        res = res.substring(0, res.length - 1) + ")";
        $("#qp").val( res);
    }
})();

執行效果

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章