sizzlemctwizzle / GM_config

A lightweight, reusable, cross-browser graphical settings framework for inclusion in user scripts.

Home Page:https://github.com/sizzlemctwizzle/GM_config/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GM_config related fails working after 'frame' object's parent change

doomred opened this issue · comments

commented

I think it's a glitch, normally nobody would mind it(including myself, I would ajust my codes right after posting this), but it just fails silently.

Let codes explain themselves:

// ==UserScript==
// @name test
// @namespace https://github.com/doomred
// @description test
// @include http://*
// @run-at document-end
// @grant GM_getValue
// @grant GM_setValue
// @require https://raw.githubusercontent.com/sizzlemctwizzle/GM_config/master/gm_config.js

// ==/UserScript==

/* init toolbar */
var classToolbar = document.createElement('div')
classToolbar.style.width = '100%';
classToolbar.style.position = 'fixed';
classToolbar.style.left = classToolbar.style.bottom = 0;
classToolbar.style.backgroundColor = '#810400';
this.document.body.appendChild(classToolbar);

/* init GM_config container */
var gmconfigDiv = document.createElement('div');  /* plan to contain setting panel */
classToolbar.appendChild(gmconfigDiv);

/* minimized one */
GM_config.init({
    'id': 'GM_config',
    'css': '#GM_config {position: static !important; width: 99% !important; margin: 1.5em auto !important; border: 0 !important;;}',  //for my style's fetish
    'frame': gmconfigDiv
});
GM_config.open();  //ok for now, you can set breakpoint here
classToolbar.innerHTML += '<span id="settingswitcher" >SETTING</span>';
// and every GM_config related stuff is not working now
/* here used to be a triiger, to GM_config.open() */
commented

As I have said this problem can be ommit, but it exists.
My codes fixed by commit blow:
doomred/hacer@09db7d2

Setting innerHTML destroys all the event listeners because it serializes and rebuilds the DOM. Don't use that.