Giter Site home page Giter Site logo

dynamic-contents-insert-js's Introduction

dynamic-contents-insert-js

JavaScriptで動的にコンテンツを追加するための汎用ライブラリ

how to use

  1. please set dynamic-contents-insert.js in your website.
  2. please set configuration javascript object.
  3. run dynamicContentsInsert(configuration) in your page.

configuration object

This is sample configuration object.

// please set Array variable.(you can set multiple rule.)
var configuration = [
    {
        // set specify the URL condition of the target page.(please use regex format)
        url: "manjiro.net\/post\/.*",
        condition:[  // condition's data can set multiple condition.(It will work any of the conditions you wrote are met.)

            {
                xpath: "h1",    //set specify the csspath of the target condition DOM object.
                text: "ゲーム紹介", //set text that will be used as the match condition.(please use regex format)
                target: "body"  //If you want to filter search DOM object, please set target csspath.

            }
        ],
        contents:[  // contents data can set multiple.(if conditions are met, run all contents key setting)

            {
                xpath: "#related",
                type: "afterbegin", // you can use 4 pattern setting(beforebegin, afterbegin,beforeend,afterend)
                content: "<div>追加したいコンテンツ情報</div>"
            }
        ]
    }
]

about "contents.type" pattern

this function use "element.insertAdjacentHTML" function. so if you want to know more detail, please see below.

https://developer.mozilla.org/ja/docs/Web/API/Element/insertAdjacentHTML

dynamic-contents-insert-js's People

Contributors

manji6 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.