// ==UserScript== // @name Tutorial Cara Cetak Sekaligus Kertas A6 Thermal // @author rendy1287 // @namespace https://rendy1287.github.io // @version 0.0.40 // @description Untuk mencetak sekaligus buat kertas ukuran A6 untuk Tokopedia, Bukalapak, Shopee, dan Akulaku // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js // @match https://www.tokopedia.com/logistic/print-address* // @match https://www.tokopedia.com/logistic/v2/print-address* // @match https://www.tokopedia.com/print-address.pl* // @match https://seller.shopee.co.id/api/v2/orders/waybill* // @match https://www.bukalapak.com/payment/transactions/print_preview* // @match https://seller.bukalapak.com/transactions/print-preview* // @match https://vendor.akulaku.com/* // @run-at document-idle // @downloadURL https://update.greasyfork.icu/scripts/371626/Tutorial%20Cara%20Cetak%20Sekaligus%20Kertas%20A6%20Thermal.user.js // @updateURL https://update.greasyfork.icu/scripts/371626/Tutorial%20Cara%20Cetak%20Sekaligus%20Kertas%20A6%20Thermal.meta.js // ==/UserScript== (function() { 'use strict'; var backgroundImage = ''; var logo = ''; if (window.location.href.indexOf("www.tokopedia.com/logistic/print-address") > -1) { cetakTokopedia(); } if (window.location.href.indexOf("www.tokopedia.com/logistic/v2/print-address") > -1) { cetakTokopediaV2(); } else if (window.location.href.indexOf("shopee") > -1) { cetakShopee(); } else if (window.location.href.indexOf("bukalapak") > -1) { cetakBukalapak(); } else if (window.location.href.indexOf("akulaku") > -1) { cetakAkulaku(); } })(); function cetakTokopedia() { var styleCSS = ``; $('body').append(styleCSS); $('div.address > table > tbody > tr > td').each(function(x, r) { $(r).find('table:contains("Kepada") > tbody > tr > td > div').css('font-size', '17px'); //$(r).find('table:contains("Kepada") > tbody > tr > th:first').append('
' + qr.createImgTag() + '
'); }); $("table div:contains('bayar asuransi')").remove(); $("div.page-break").remove(); $("td div:contains('Asuransi')").next().html('+ Rp 0').css('text-decoration', 'none'); $("td div:contains('Ongkir')").next().css('text-decoration', 'none'); $("div.address_container_right").each(function() { if ($(this).children().length == 0) { $(this).remove(); } }); $("div.address").filter(function() { return $(this).text().trim() == ""; }).remove(); $("div.address_container_right").filter(function() { return $(this).text().trim() == ""; }).remove(); } function cetakTokopediaV2() { var styleCSS = ``; $('body').append(styleCSS); $('div.address > table > tbody > tr > td').each(function(x, r) { $(r).find('table:contains("Kepada") > tbody > tr > td > div').css('font-size', '17px'); }); $("table div:contains('bayar asuransi')").remove(); $("div.page-break").remove(); $("td div:contains('Asuransi')").next().html('+ Rp 0').css('text-decoration', 'none'); $("td div:contains('Ongkir')").next().css('text-decoration', 'none'); $("div.address_container_right").each(function() { if ($(this).children().length == 0) { $(this).remove(); } }); $("div.address").filter(function() { return $(this).text().trim() == ""; }).remove(); $("div.address_container_right").filter(function() { return $(this).text().trim() == ""; }).remove(); } function cetakShopee() { var styleCSS = ``; $('style:last').html($('style:last').html().replace('A4 landscape', 'auto')); $('style:first').html($('style:first').html().replace('A4 landscape', 'auto')); $('style:nth-of-type(2)').html($('style:nth-of-type(2)').html().replace('A4 landscape', 'auto')); $('style:first').html($('style:first').html().replace('size: landscape; margin: 0.1in 0.2in;', 'size: auto;')); $('head').append(styleCSS); $('div.page-breaker').remove(); $('div:last').remove(); $('img.scissors-vertical').remove(); $('div.scissors_icon').remove(); $(".page.right").each(function() { if ($("div.job-shipping-label", this).length > 0) { $("style:last").html($('style:last').html().replace(/(padding: 0 0.55in 0 0;)/g, "")); } }); //$("div.page:has(div.job-shipping-label)").css("width", "550px"); //$("div.page:has(div.jne_reg_shipping_label)").css("width", "565px"); $("div.container:has(div.right) > div.page:has(div.job-shipping-label)").css("width", "530px"); } function cetakBukalapak() { var styleCSS = ``; $('body').append(styleCSS); } let label = `
Label Pengiriman
{{ekspedisi}}
Order No.
{{orderno}}
Invoice Number
{{invoice}}
Administrasi
{{administrasi}}
Asuransi
{{asuransi}}
SubTotal
{{ongkir}}
Tanggal
{{berat}}
Kepada
{{nama_penerima}} - {{telepon_penerima}}
Alamat
{{alamat_penerima}}
Dari
{{nama_pengirim}} - {{telepon_pengirim}}
{{alamat_pengirim}}
{{foreach_item}}
`; // foreach_item menggunakan template ini let item = `
{{jumlah_produk}}
{{nama_produk}}{{sku}}
Keterangan: {{keterangan_produk}}
`; let css = ` `; var js = ` `; var currentPage = ''; function cetakAkulaku() { var initWatcher = ''; initWatcher = setInterval(function () { //console.log('watch'); if (unsafeWindow.angular) { //clearInterval(initWatcher); if (/index\/processingOrders/.test(window.location.href) && currentPage != 'https://vendor.akulaku.com/#/index/processingOrders') { $('button.btn.btn-success.btn-sm').first().after(''); currentPage = 'https://vendor.akulaku.com/#/index/processingOrders'; cetakAkulaku2(0, 10, 1); //showDeadline(1); } else if (/index\/preparingOrders/.test(window.location.href) && currentPage != 'https://vendor.akulaku.com/#/index/preparingOrders') { $('button.btn.btn-success.btn-sm').first().after(''); currentPage = 'https://vendor.akulaku.com/#/index/preparingOrders'; cetakAkulaku2(0, 10, -1); //showDeadline(-1); } else { currentPage = window.location.href; } } }, 100); } function cetakAkulaku2(offset = 0, count = 10, status = 1) { //https://vendor.akulaku.com/installment/api/json/vendor/delivered/sales/order/list.do?offset=0&count=10 //https://vendor.akulaku.com/installment/api/json/vendor/pending/delivery/sales/order/list.do?offset=10&count=10&status=1 console.log('angular: ' + unsafeWindow.angular); $.getJSON('https://vendor.akulaku.com/installment/api/json/vendor/pending/delivery/sales/order/list.do?offset=' + offset + '&count=' + count + '&status=' + status, function() { console.log( "success" ); }) .done(function(data) { console.log( "second success" ); var jumlah = data.data.list.length; var list, html = ''; html += 'Cetak Slip Alamat'; html += css; html += ''; html += js; html += `
Cetak Previous Next