Autopost VK

Autopost для VK

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Autopost VK
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Autopost для VK
// @author       ʄɛռɨx
// @include      https://vk.com/(указываем свою страничку)
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    
   let
     text = 'text with #tampermonkey #userscript',
     date = new Date(2023,10,26,10,1).getTime()/1000;
    let
      send_post  = document.querySelector('#send_post'),
      post_field = document.querySelector('#post_field'),
      post_action= document.querySelectorAll('.post_action_btn_layout')[1],
      postpone   = document.querySelector('#postpone_date1');

post_field.focus();
post_field.innerHTML = text;
    
    simulateClick(post_action);
    postpone   = document.querySelector('#postpone_date1');
    
    postpone.value = date;
    send_post.click();
    
})();

function simulateClick(element){
    let ev = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true,
    });
    let canceled = !element.dispatchEvent(ev);
    return canceled;
}