Greasy Fork is available in English.

Name Copy & Paste By 5A LD

Menu For Copy Names In Agar.io and other agar by 5A LD

< Name Copy & Paste By 5A LDについてのフィードバック

質問/コメント

§
投稿日: 2017/07/06

Simplification

Hey, just wanted to let you know you can simplify the inject function to:

function inject(type, code) {
    var inject  = document.createElement(type);
    inject.type = 'text/' + (type == 'script' ? 'javascript' : 'css'); // You don't even really need this line..
    inject.textContent = code;
    (document.head || document.documentElement).appendChild(inject);
}

// Only functional difference from before is the type arguments it accepts is 'script' and 'style'.
// Line 3 uses a ternary operator:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator 

返信を投稿

返信を投稿するにはログインしてください。