When the VueJS element is rendered on Chrome addon, it suddenly vanishes

I have been using a developer mode addon successfully in Chrome for quite some time.

Now, I want to add a button to my Vue-powered page. Here's the code snippet:


        let isletCtl = document.createElement('div')
        isletCtl.id = "islet-ctl"
        isletCtl.innerText = 'isletCtl: '

        let isletVue = document.createElement('div')
        isletVue.id = 'islet-vue'
        isletVue.innerText = 'isletVue: {{ response }}'
        isletCtl.appendChild(isletVue)
        document.body.appendChild(isletCtl)

        window.setTimeout(function(){
            new Vue({
                el: "#islet-vue",
                data: function(){
                    return {response: 'hello vue'}
                }
            })
        }, 25000)
    

The 25-second delay was just for troubleshooting purposes. The button appears fine initially, but once the Vue rendering happens with Vue({ ... }), the #islet-vue div disappears from the DOM!

Can anyone provide any insight into why this might be happening?

EDIT: Take a look at this screenshot from the Chrome Inspector. It seems like a comment is added, but the actual div#islet-vue element vanishes. https://i.stack.imgur.com/1Np3q.png

EDIT 2: This is my manifest.json file:

{
        "name": "XXX",
        "version": "0.0.3",
        "manifest_version": 3,
        "description": "Simple secure plugin that converts Jira-like text in Slack.",
        "content_scripts": [
            {
                "js": ["js/vue-2.1.6.min.js","tools.js", "common.js", "app.slack.com.v2.js"],
                "css": ["app.slack.com.css"],
                "matches": ["https://app.slack.com/client/*"]
            },
            {
                "js": ["tools.js","common.js","develop/localhost.43000.js"],
                "css": ["develop/localhost.43000.css"],
                "matches": ["http://localhost:43000/*"]
            }
        ],
        "action": {
            "browser_style": true,
            "default_title": "X Islet CORS popup",
            "default_popup": "popup.html"
        },
        "permissions": [
            "tabs",
            "bookmarks",
            "storage"
        ],
        "host_permissions": [
            "http://localhost:8080/",
            "http://localhost:43000/",
            "http://52.117.30.181/*"
        ]
    }

Answer №1

Seems like the issue arises from Vue not having the necessary permissions to manipulate a string on the page from an addon. To resolve this, consider adding a render function to your Vue instance

new Vue({
    el: "#islet-vue",
    render: function(createElement) {
        return createElement('div', {}, this.message)
    },
    data: function() {
        return {
            response: 'hello vue'
        }
    }
})

The problem could be related to how you import Vue, so utilizing webpack (or browserify) can simplify the process of importing external packages.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implementing fetch within a custom hook to display a loader within a return function

customFetch hook: import React, { useState, useEffect } from 'react'; const customFetch = (url, options) => { const [response, setResponse] = useState(null); const [error, setError] = useState(null); useEffect(() => { (async () ...

Iterate over the array and show the elements only when a click event occurs

I am trying to create a loop through an array (array) and display the elements one by one only after clicking a button (bt). However, when I run this code, it only shows the last element of the array (i.e. honda). Can someone please help me fix this issu ...

The side menu in Bootstrap dropdown experiences a one-time functionality

When navigating through a responsive top menu with Bootstrap, everything works seamlessly - from toggling the menu to dropdown functionality. However, I encountered an issue with the side menu as nav-pills used to select tab-panes. <div class="containe ...

The React context is currently yielding an undefined value

I am puzzled by this issue. I have double-checked to ensure that the states value is not undefined, and it isn't. However, I am unable to pinpoint where I may be making a mistake. Here is my authContext.js file: const initialState = { isAuthorized: ...

What could be causing the issue with my css `content:` not functioning across different browsers, and how can I enhance cross-browser compatibility in all cases

Working on my first HTML/CSS project, I encountered a browser compatibility challenge. The code functions well in Firefox, IE, and Edge but fails in Chrome. Specifically, I am trying to make a button display alternating up and down arrows when clicked. Whi ...

Ways to extract values from a javascript hash map by exclusively incorporating an array

So here's the issue I'm encountering. Let's consider the following scenario: let surfaces: Map<any, any> = new Map([{"83.1" => Object}, {"84.1" => Object}]) let arr1 = ["83.1"] This is the desired o ...

Using JavaScript, retrieve the ID of a child element by utilizing details about the parent element

I have implemented a JavaScript function that creates a div element. Within this div, there are multiple checkboxes as child elements. My goal is to use a loop to extract the ids of all these checkboxes. The div has been assigned to a variable named: o ...

The axios requests are sent to the backend API, but the webpage remains empty without

I am trying to retrieve a base64 encoded image from my local backend by making a local API call. The logging on the backend confirms that axios is successfully calling the API, however, the frontend displays an empty page with no data. What could be caus ...

NodeJS rendering method for HTML pages

We are in the process of developing a fully functional social networking website that will resemble popular platforms like Facebook or Instagram. Our plan is to utilize Node.js on the server side and we are currently exploring the best technology for rende ...

Struggling to make button switch in my Spring Boot Application (e.g. from "Add to Cart" to "Remove")

My application allows users to add items to their cart, which are then persisted using Spring Data JPA and saved in a MySQL database. I am looking to change the text from "Add to Cart" to "Remove" when the button is clicked, and vice versa. I have attempt ...

Ways to remove any messages containing URLs that are not www.youtube.com or www.twitter.com

Recently, I have encountered a significant issue with Discord Scam Links in my server. I attempted the following approach: if(message.content.includes("discordscam.com")) { message.delete() } However, this method is not effective as it onl ...

Endless Google Locations Instances

My database entries are being displayed in a table using input fields. I want the Location field for each entry to be automatically completed using Google's API. HTML: <input name="edit_airplane[1][location]" type="text" class="airplane_location" ...

Move a <div> using a handle (without using JQuery)

I devised a plan to create a moveable div with a handle and came up with this code snippet: var mydragg = function() { return { move: function(divid, xpos, ypos) { divid.style.left = xpos + 'px'; divid.style.top = ypos + &apo ...

Tips for correctly cloning a table row:

Currently, I am engaged with a Django project that involves incorporating a form within a table structure. <table name="mytable" id="table_purchase" role="grid"> <thead> <tr> <th class="text-center" hidden>No</th& ...

The error of "Uncaught ReferenceError" is being triggered by the use of `process?.env?

A bug was discovered in our front-end code related to the following snippet: <span style={{ color: 'red' }}>{process?.env?.REACT_APP_HEADER_SUFFIX ?? ''}</span> The bug triggered the following error message: Uncaught Refere ...

Setting up NestJs with TypeORM by utilizing environment files

In my setup, I have two different .env files named dev.env and staging.env. My database ORM is typeorm. I am seeking guidance on how to configure typeorm to read the appropriate config file whenever I launch the application. Currently, I am encountering ...

Choose an option from a list of items in a nested array by

I'm working with a nested array (3d) and I want to populate a drop-down select menu with its values using PHP and jQuery I've tried implementing this for two-level arrays like categories and sub-categories, but what if some sub-categories have f ...

Experiencing difficulties establishing a connection between the React client and Node.js server using SocketIO

I am currently getting familiar with socketIO and have successfully set up a basic nodejs server. However, I am facing an issue where my nextJS app is unable to connect to the server as expected. Despite no errors being displayed, the messages that should ...

Exploring the combined application of the AND and OR operators in JavaScript programming

{Object.keys(groupByMonthApplicants).map((obj,i) => <div key={obj} style={(i > 0 && (this.state.selectedTabId !== 'rejected' || this.state.selectedTabId !== 'approved')) ? {paddingTop:'15px',background:&a ...

Ajax displays JSON data within an array format

Looking for a solution where I have MySQL data displayed in a table, with each row having a button. When the button is clicked, a bootstrap modal should appear containing that data. I have converted the MySQL data to JSON format and assigned the ".view_dat ...