Forumsvar skapade

Visar 2 inlägg - 1 till 2 (av 2 totalt)
  • Författare
    Inlägg
  • #181279
    Jon82
    Deltagare

    @Björn 86654 wrote:

    Nej det funkar inte. Postnord har ändrat en del och verkligen försökt göra det svårt. Har dock en uppdaterad version nedan som fungerar. Jag kör detta i Tampermonkey. Du får ändra lite i scriptet så det passar din shop. Jag lämnar ingen support på det tyvärr.

    // ==UserScript==
    // @name skickalatt
    // @namespace http://www.dindomän.se
    // @author Björn Hansson
    // @description Posten skicka lätt – Autofill script
    // @include http://skicka2.posten.se/*
    // @include https://www.dindomän.se*
    // @version 009
    // ==/UserScript==

    // Base url identifier of page to collect address from
    var customer_info_url_base = “?controller=orders&action=setOrder&id=”;

    // When object is clicked on the above page address is collected
    var object_to_click = “#tabs input[name=shipping_firstname]”;

    // Attach the collect_address function to above object on the page to copy address from
    if (window.location.href.indexOf(customer_info_url_base) > -1)
    {
    $(object_to_click).click(collect_address);
    }
    else if (GM_getValue(“collected”) == 1 && document.location.href.indexOf(“/Sidor/Start.aspx”)>-1)
    { // Posten skicka lätt page: If address is collected and we are at postens page for skicka lätt

    // Weight
    /*
    if(GM_getValue(“weight”) <= 1000) { $('.skickaInput #ctl00_PlaceHolderMain_ServiceSettings_WeightSettings_RadioButtonListWeights_0').trigger("click"); } else { $('.skickaInput #ctl00_PlaceHolderMain_ServiceSettings_WeightSettings_RadioButtonListWeights_1').trigger("click"); } */ setTimeout(function(){ $('#SelectServiceDisplay > div:first-child > div:nth-child(3) select option’).filter(function(){return this.text==’Brev Skicka Lätt’;}).attr(‘selected’,true);
    $(‘#SelectServiceDisplay > div:first-child > div:nth-child(3) select option’).filter(function(){return this.text==’Brev Skicka Lätt’;}).attr(‘selected’,true).closest(‘select’).trigger(‘change’);
    $(‘#SelectServiceDisplay .rightPartSize .leftFloat.sizeInput .field.smallestField’).val(’15’);
    $(‘#SelectServiceDisplay .rightPartSize .leftFloat.sizeInput .field.smallestField’).trigger(‘change’);
    $(‘#SelectServiceDisplay .rightPart.rightPartText .field.mediumField’).val(‘1’).trigger(‘change’);
    $(‘.buttonContainer.rightFloat.bottomMargin .largeButton.mainButton’).trigger(‘click’);
    }, 2000);

    setTimeout(function(){
    // Sender details
    $(“#SenderAddressDisplay .rightPart.rightPartText input[type=radio]:eq(1)”).trigger(‘click’).trigger(‘click’); // Avsändare: Företag
    $(“#SenderAddressDisplay > div:first-child > div:nth-child(2) > div:nth-child(4) > div:nth-child(2) .field.largestField”).val(‘Företagsnamn’).trigger(‘change’); // Företagsnamn
    $(“#SenderAddressDisplay > div:first-child > div:nth-child(2) > div:nth-child(5) .rightPart .field.largestField”).val(‘555555-5555’).trigger(‘change’); // Organisationsnummer
    $(“#senderZipCode”).val(‘12345’).trigger(‘change’); // Postnummer
    $(“#senderEmail”).val(‘info@dindomän.se’).trigger(‘change’); // E-post
    $(“#senderEmailConfirm”).val(‘info@dindomän.se’).trigger(‘change’); // Bekräfta e-post

    // Customer details
    $(‘#kgRadio’).trigger(‘click’); // Mottagare: Privat
    $(‘#receiverName’).val(GM_getValue(“firstname”)+’ ‘+GM_getValue(“lastname”)).trigger(‘change’); // Namn
    $(‘#ReceiverAddress’).val(GM_getValue(“address1”)).trigger(‘change’); // Adress rad 1
    $(‘#receiverAddress2’).val(GM_getValue(“address2”)).trigger(‘change’); // Address rad 2
    $(‘#receiverEmail’).val(GM_getValue(“email”)).trigger(‘change’); // E-post
    $(‘#receiverEmailConfirm’).val(GM_getValue(“email”)).trigger(‘change’); // Bekräfta e-post
    $(‘#receiverMobilePhone’).val(GM_getValue(“phone”)).trigger(‘change’); // Mobil
    $(‘#receiverZipCode’).val(GM_getValue(“zipcode”)).trigger(‘change’); // Postnummer (triggar ifyllning av ort automatiskt)
    }, 3000);
    }

    function collect_address()
    {
    GM_setValue(“order_id”, $(“input[name=order_id]”).val() );
    GM_setValue(“firstname”, $(“input[name=shipping_firstname]”).val() );
    GM_setValue(“lastname”, $(“input[name=shipping_lastname]”).val() );
    GM_setValue(“email”, $(“input[name=shipping_email]”).val() );
    GM_setValue(“address1”, $(“input[name=shipping_address1]”).val() );
    GM_setValue(“address2”, $(“input[name=shipping_address2]”).val() );
    GM_setValue(“zipcode”, $(“input[name=shipping_zipcode]”).val().split(‘ ‘).join(”) ); // Strippa bort space
    GM_setValue(“city”, $(“input[name=shipping_city]”).val() ); // Behövs inte, autofylls av posten..
    GM_setValue(“phone”, $(“input[name=shipping_phone]”).val().split(‘ ‘).join(”) ); // Strippa bort space

    /*
    var weight = 0;
    if($(“input[name=weight]”).val()){ weight = $(“input[name=weight]”).val(); }

    GM_setValue(“weight”, weight );
    */

    if(document.location.href.indexOf(“www.dindomän.se”)>-1)
    {
    GM_setValue(“fromName”, “Från namn”);
    GM_setValue(“fromEmail”, “info@dindomän.se”);
    }

    GM_setValue(“collected”, “1”);
    alert(“Address of ” + GM_getValue(“firstname”) + ” ” + GM_getValue(“lastname”) + ” collected. You are now redirected to posten.se”);
    window.open(“http://skicka2.posten.se/Sidor/Start.aspx&#8221;);
    }
    [/CODE]

    Notera att vikten är utkommenterat, kan fyllas i manuellt om man inte har det i något fält.

    Tack, ska försöka få ordning. Ingen höjdare på programmering men gör ett försök[CODE]
    // ==UserScript==
    // @name skickalatt
    // @namespace http://www.dindomän.se
    // @author Björn Hansson
    // @description Posten skicka lätt – Autofill script
    // @include http://skicka2.posten.se/*
    // @include https://www.dindomän.se*
    // @version 009
    // ==/UserScript==

    // Base url identifier of page to collect address from
    var customer_info_url_base = “?controller=orders&action=setOrder&id=”;

    // When object is clicked on the above page address is collected
    var object_to_click = “#tabs input[name=shipping_firstname]”;

    // Attach the collect_address function to above object on the page to copy address from
    if (window.location.href.indexOf(customer_info_url_base) > -1)
    {
    $(object_to_click).click(collect_address);
    }
    else if (GM_getValue(“collected”) == 1 && document.location.href.indexOf(“/Sidor/Start.aspx”)>-1)
    { // Posten skicka lätt page: If address is collected and we are at postens page for skicka lätt

    // Weight
    /*
    if(GM_getValue(“weight”) <= 1000)
    {
    $(‘.skickaInput #ctl00_PlaceHolderMain_ServiceSettings_WeightSettings_RadioButtonListWeights_0’).trigger(“click”);
    }
    else
    {
    $(‘.skickaInput #ctl00_PlaceHolderMain_ServiceSettings_WeightSettings_RadioButtonListWeights_1’).trigger(“click”);
    }
    */

    setTimeout(function(){
    $(‘#SelectServiceDisplay > div:first-child > div:nth-child(3) select option’).filter(function(){return this.text==’Brev Skicka Lätt’;}).attr(‘selected’,true);
    $(‘#SelectServiceDisplay > div:first-child > div:nth-child(3) select option’).filter(function(){return this.text==’Brev Skicka Lätt’;}).attr(‘selected’,true).closest(‘select’).trigger(‘change’);
    $(‘#SelectServiceDisplay .rightPartSize .leftFloat.sizeInput .field.smallestField’).val(’15’);
    $(‘#SelectServiceDisplay .rightPartSize .leftFloat.sizeInput .field.smallestField’).trigger(‘change’);
    $(‘#SelectServiceDisplay .rightPart.rightPartText .field.mediumField’).val(‘1’).trigger(‘change’);
    $(‘.buttonContainer.rightFloat.bottomMargin .largeButton.mainButton’).trigger(‘click’);
    }, 2000);

    setTimeout(function(){
    // Sender details
    $(“#SenderAddressDisplay .rightPart.rightPartText input[type=radio]:eq(1)”).trigger(‘click’).trigger(‘click’); // Avsändare: Företag
    $(“#SenderAddressDisplay > div:first-child > div:nth-child(2) > div:nth-child(4) > div:nth-child(2) .field.largestField”).val(‘Företagsnamn’).trigger(‘change’); // Företagsnamn
    $(“#SenderAddressDisplay > div:first-child > div:nth-child(2) > div:nth-child(5) .rightPart .field.largestField”).val(‘555555-5555’).trigger(‘change’); // Organisationsnummer
    $(“#senderZipCode”).val(‘12345’).trigger(‘change’); // Postnummer
    $(“#senderEmail”).val(‘info@dindomän.se’).trigger(‘change’); // E-post
    $(“#senderEmailConfirm”).val(‘info@dindomän.se’).trigger(‘change’); // Bekräfta e-post

    // Customer details
    $(‘#kgRadio’).trigger(‘click’); // Mottagare: Privat
    $(‘#receiverName’).val(GM_getValue(“firstname”)+’ ‘+GM_getValue(“lastname”)).trigger(‘change’); // Namn
    $(‘#ReceiverAddress’).val(GM_getValue(“address1”)).trigger(‘change’); // Adress rad 1
    $(‘#receiverAddress2’).val(GM_getValue(“address2”)).trigger(‘change’); // Address rad 2
    $(‘#receiverEmail’).val(GM_getValue(“email”)).trigger(‘change’); // E-post
    $(‘#receiverEmailConfirm’).val(GM_getValue(“email”)).trigger(‘change’); // Bekräfta e-post
    $(‘#receiverMobilePhone’).val(GM_getValue(“phone”)).trigger(‘change’); // Mobil
    $(‘#receiverZipCode’).val(GM_getValue(“zipcode”)).trigger(‘change’); // Postnummer (triggar ifyllning av ort automatiskt)
    }, 3000);
    }

    function collect_address()
    {
    GM_setValue(“order_id”, $(“input[name=order_id]”).val() );
    GM_setValue(“firstname”, $(“input[name=shipping_firstname]”).val() );
    GM_setValue(“lastname”, $(“input[name=shipping_lastname]”).val() );
    GM_setValue(“email”, $(“input[name=shipping_email]”).val() );
    GM_setValue(“address1”, $(“input[name=shipping_address1]”).val() );
    GM_setValue(“address2”, $(“input[name=shipping_address2]”).val() );
    GM_setValue(“zipcode”, $(“input[name=shipping_zipcode]”).val().split(‘ ‘).join(”) ); // Strippa bort space
    GM_setValue(“city”, $(“input[name=shipping_city]”).val() ); // Behövs inte, autofylls av posten..
    GM_setValue(“phone”, $(“input[name=shipping_phone]”).val().split(‘ ‘).join(”) ); // Strippa bort space

    /*
    var weight = 0;
    if($(“input[name=weight]”).val()){ weight = $(“input[name=weight]”).val(); }

    GM_setValue(“weight”, weight );
    */

    if(document.location.href.indexOf(“www.dindomän.se”)>-1)
    {
    GM_setValue(“fromName”, “Från namn”);
    GM_setValue(“fromEmail”, “info@dindomän.se”);
    }

    GM_setValue(“collected”, “1”);
    alert(“Address of ” + GM_getValue(“firstname”) + ” ” + GM_getValue(“lastname”) + ” collected. You are now redirected to posten.se”);
    window.open(“http://skicka2.posten.se/Sidor/Start.aspx&#8221;);
    }
    [/CODE]

    Notera att vikten är utkommenterat, kan fyllas i manuellt om man inte har det i något fält.

    Tack, ska försöka få ordning. Ingen höjdare på programmering men gör ett försök

    #181257
    Jon82
    Deltagare

    @jonas32 78040 wrote:

    Jepp, fick allt att funka på båda mina shoppar. Så perfekt :) Tack.
    Finns det någon som kan hjälpa mig hur man lägger det i varukorgen automatiskt också så vore det dunder :)

    Hej.. fungerar det här fortfarande?
    Kan verkligen ingenting om att programmera så all hjälp uppskattas.

    Skulle älska att få igång det här till webshopen.

Visar 2 inlägg - 1 till 2 (av 2 totalt)