// ==UserScript== // @name Cetak Sekaligus Kertas A6 // @author Celleven Store // @namespace https://www.tokopedia.com/celleven // @version 0.0.20 // @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 // @match https://www.tokopedia.com/logistic/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 http://vendor.akulaku.com/* // @run-at document-idle // @downloadURL none // ==/UserScript== (function() { 'use strict'; var backgroundImage = ''; var logo = ''; if (window.location.href.indexOf("tokopedia") > -1) { cetakTokopedia(); } 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'); }); $("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_contaier_right").each(function() { if ($(this).children().length == 0) { $(this).remove(); } }); $("div.address").filter(function() { return $(this).text().trim() == ""; }).remove(); $("div.address_contaier_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: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.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}}
Nomor Invoice
{{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 = ` `; function cetakAkulaku() { var initWatcher = ''; if (/index\/processingOrders/.test(window.location.href)) { initWatcher = setInterval(function () { console.log('watch'); if (unsafeWindow.angular) { clearInterval(initWatcher); cetakAkulaku2(1); } }, 100); } else if (/index\/preparingOrders/.test(window.location.href)) { initWatcher = setInterval(function () { console.log('watch'); if (unsafeWindow.angular) { clearInterval(initWatcher); cetakAkulaku2(-1); } }, 100); }; } function cetakAkulaku2(status) { console.log('angular', unsafeWindow.angular); $.getJSON('http://vendor.akulaku.com/installment/api/json/vendor/pending/delivery/sales/order/list.do?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 += '
Cetak