housejoy print script

enter something useful

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         housejoy print script
// @namespace    http://admin.housejoy.in/get-open-jobs
// @version      0.1
// @description  enter something useful
// @author       Chanakya Gujju ([email protected])
// @match        http://admin.housejoy.in/get-open-jobs
// @grant        none
// ==/UserScript==


function my_print(id) {
    console.log("Print on this called - "+id);
    console.log(id);

    var divToPrint=document.getElementById(id);
    newWin= window.open("");
    newWin.document.write(divToPrint.outerHTML);
    newWin.print();
    newWin.close();
}

var table = document.getElementsByClassName("table table-hover table-striped");

var rows = document.getElementsByTagName("tr");

console.log(table[0]);

console.log(table[0].rows[1]);

var one_row = (table[0].rows[2]).getElementsByTagName("td");

console.log(one_row);

console.log(one_row[1].innerText);

for(var i = 1; i<(rows.length); i++) {
    var table_rem = (i-1)%100;
    var row_rem = (i-1)%10;
    var table_row;
    var table_id;
    var new_table;
    if(table_rem == 0){

        document.body.appendChild(document.createElement("br"));
        table_id = i;
        new_table = document.createElement("TABLE");
        new_table.align = "center";
        new_table.border = 1;
        new_table.setAttribute("id", table_id);
        document.body.appendChild(new_table);

        insrow = new_table.insertRow(0);
        var cell1 = insrow.insertCell(0);
        var btn = document.createElement('button');
        var t = document.createTextNode("PRINT");
        btn.id = table_id;
        btn.appendChild(t);
        btn.addEventListener('click', function(e) {
            console.log(this.parentNode.id);
            console.log(this.id);
            my_print(this.id);
        }, false);
        cell1.appendChild(btn);        

        table_row = table_id+i
        var y = document.createElement("TR");
        y.setAttribute("id", table_row);
        document.getElementById(table_id).appendChild(y);
        var z = document.createElement("TD");

        var one_row = (table[0].rows[i]).getElementsByTagName("td");
        var text = one_row[1].innerText

        var t = document.createTextNode(text);
        z.appendChild(t);
        document.getElementById(table_row).appendChild(z);

    } else {
        if(row_rem == 0) {
            table_row = table_id+i
            var y = document.createElement("TR");
            y.setAttribute("id", table_row);
            document.getElementById(table_id).appendChild(y);
            var z = document.createElement("TD");

            var one_row = (table[0].rows[i]).getElementsByTagName("td");
            var text = one_row[1].innerText

            var t = document.createTextNode(text);
            z.appendChild(t);
            document.getElementById(table_row).appendChild(z);
        } else {
            var z = document.createElement("TD");

            var one_row = (table[0].rows[i]).getElementsByTagName("td");
            var text = one_row[1].innerText

            var t = document.createTextNode(text);
            z.appendChild(t);
            document.getElementById(table_row).appendChild(z);
        }
    }
}