I am pretty new in Tampermonkey Javascript and inherited below script to create a button and hoping to select a file upon click.
However, the import data button is not showing in https://test.com/*. I have tested alert("hi"); code in https://test.com/* and it is working fine. Can somebody help me with the solution? What is wrong with the code? Or is it me since I'm noob :) Thank you very much in advance.
// ==UserScript==
// @name Test Tampermonkey Script
// @version 0.1
// @description Test
// @author Me
// @match https://test.com/*
// @grant GM_xmlhttpRequest
// @grant GM_info
// ==/UserScript==
(function() {
'use strict';
function importData() {
let input = document.createElement('input');
input.type = 'file';
input.onchange = _ => {
// you can use this method to get file and perform respective operations
let files = Array.from(input.files);
console.log(files);
};
input.click();
}
})();