{"id":6117,"date":"2018-06-18T21:29:06","date_gmt":"2018-06-18T12:29:06","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=6117"},"modified":"2022-04-22T23:41:51","modified_gmt":"2022-04-22T14:41:51","slug":"%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%81%a7%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88%e3%82%92%e5%81%9c%e6%ad%a2%e3%81%95%e3%81%9b%e3%82%8b%e3%81%93%e3%81%a8%e3%81%ae%e9%9b%a3%e3%81%97","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/javascript\/6117","title":{"rendered":"[\u8ffd\u8a18]\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u505c\u6b62\u3055\u305b\u308b\u3053\u3068\u306e\u96e3\u3057\u3055\u3002"},"content":{"rendered":"\n<p>\u300c<a href=\"https:\/\/gunmagisgeek.com\/blog\/javascript\/6114\">\u30b5\u30a4\u30c8\u4e0a\u3067\u5b9f\u884c\u3055\u308c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3064\u3044\u3066\u540c\u610f\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306e\u30d7\u30ed\u30b0\u30e9\u30e0<\/a>\u300d\u3068\u3044\u3046\u8a18\u4e8b\u3067\u3001MutationObserver\u3092\u4f7f\u3063\u3066script\u30bf\u30b0\u304cDOM\u306b\u8ffd\u52a0\u3055\u305b\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067remove\u3092\u884c\u3046\u3068\u3044\u3046\u529b\u696d\u3092\u8a66\u3057\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u306b\u3082\u5b8c\u5168\u306b\u5b9f\u884c\u3092\u505c\u6b62\u3059\u308b\u306e\u306f\u96e3\u3057\u3044\u3088\u3046\u3067\u3059\u3002<br>\u3082\u3068\u3082\u3068\u3001\u672c\u6765\u306fhead\u30bf\u30b0\u76f4\u4e0b\u3067\u5b9f\u884c\u3059\u3079\u304d\u30b3\u30fc\u30c9\u3092\u8a18\u4e8b\u6587\u4e2d\u5185\u3067\u5b9f\u884c\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u8a18\u4e8b\u4ee5\u524d\u306b\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308bscript\u306b\u95a2\u3057\u3066\u306f\u5b9f\u884c\u3092\u6b62\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u307b\u304b\u306b\u3082async\u5c5e\u6027\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u95a2\u3057\u3066\u306f\u3053\u306e\u65b9\u6cd5\u3067\u306f\u5b9f\u884c\u3092\u6b62\u3081\u308b\u3053\u3068\u306f\u3067\u304d\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u4e00\u5ea6\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u6b8b\u308b\u305f\u3081\u30012\u56de\u76ee\u306b\u30da\u30fc\u30b8\u3092\u8868\u793a\u3057\u305f\u969b\u306b\u6b63\u3057\u304f\u52d5\u4f5c\u3057\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30d5\u30c3\u30af\u3057\u3066\u5b9f\u884c\u3092\u5236\u5fa1\u3059\u308b\u306e\u306f\u306a\u304b\u306a\u304b\u306b\u96e3\u554f\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">[\u8ffd\u8a18]\u691c\u8a3c\u30da\u30fc\u30b8\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/h3>\n\n\n\n<p>\u203b\u30ea\u30f3\u30af\u5148\u306e\u691c\u8a3c\u30da\u30fc\u30b8\u306b\u98db\u3076\u524d\u306b\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u958b\u3044\u3066\u304a\u304f\u3068\u624b\u9593\u304c\u4e00\u3064\u6e1b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"http:\/\/shimz.me\/example\/js\/scriptControl\/\">\u691c\u8a3c\u30da\u30fc\u30b8<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u691c\u8a3c\u30da\u30fc\u30b8\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html&gt;\n&lt;html lang=\"jp\"&gt;\n&lt;head&gt;\n&lt;script type=\"text\/javascript\"&gt;\nwindow.alert(\"\u3053\u306e\u30da\u30fc\u30b8\u306fJavaScript\u306e\u5b9f\u884c\u3092JavaScript\u3067\u5236\u5fa1\u3059\u308b\u691c\u8a3c\u30da\u30fc\u30b8\u3067\u3059\u3002\");\nconst observer = new MutationObserver(mutations =&gt; {\n    mutations.forEach(({ addedNodes }) =&gt; {\n        addedNodes.forEach(node =&gt; {\n            if(node.nodeType === 1 &amp;&amp; node.tagName === 'SCRIPT') {\n                const src = node.src || ''\n                const type = node.type;\n                let script = \"\";\n                if(src){\n                    script = src;\n                }else{\n                    script = node.innerHTML;\n                }\n                let check = window.confirm(\"\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u3092\u8a31\u53ef\u3057\u307e\u3059\u304b\uff1fn\"+script);\n                console.log(\"\u30c0\u30a4\u30a2\u30ed\u30b0\u623b\u308a\u5024:\"+check);\n                if(check){\n                    \/\/console.log(\"run\", script);\n                }else{\n                    console.log(\"\u4ee5\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u524a\u9664\u3057\u307e\u3057\u305f\", script);\n                    node.remove();                    \n                }\n            }\n        })\n    })\n});\nobserver.observe(document.documentElement, {\n    childList: true,\n    subtree: true\n});\n&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;\u30b9\u30af\u30ea\u30d7\u30c8\u5236\u5fa1\u691c\u8a3c\u30da\u30fc\u30b8&lt;\/h1&gt;\n&lt;p&gt;\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u3092\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u5236\u5fa1\u3057\u95b2\u89a7\u8005\u304c\u3001\u5b9f\u884c\u306e\u8a31\u53ef\u30fb\u4e0d\u8a31\u53ef\u3092\u9078\u629e\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u30c7\u30e2\u3067\u3059&lt;\/p&gt;\n&lt;p&gt;\u30a4\u30f3\u30e9\u30a4\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u3001\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3001\u305d\u308c\u305e\u308c\u540c\u671f\uff0f\u975e\u540c\u671f\u304c\u6307\u5b9a\u3055\u308c\u305f\uff14\u3064\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u3001Google \u30a2\u30c9\u30bb\u30f3\u30b9(\u540c\u671f\uff0f\u975e\u540c\u671f)\u3001Google \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u8a2d\u7f6e\u3057\u3066\u3042\u308a\u307e\u3059\u3002&lt;\/p&gt;\n&lt;p&gt;\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u627f\u8a8d\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u5b9f\u884c\u7d50\u679c\u304c\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u62d2\u5426\u3055\u308c\u305f\u5834\u5408\u306f\u3001\u540c\u3058\u304f\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u300c\u524a\u9664\u3057\u307e\u3057\u305f\u300d\u3068\u8868\u793a\u3055\u308c\u307e\u3059&lt;\/p&gt;\n\n    \n&lt;script&gt;\nconsole.log(\"%c%s\",\n            \"color: red; background: yellow; font-size: 24px;\",\n            \"\u540c\u671f\u30a4\u30f3\u30e9\u30a4\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3057\u305f\")&lt;\/script&gt;\n\n&lt;script async&gt;\nconsole.log(\"%c%s\",\n            \"color: red; background: yellow; font-size: 24px;\",\n            \"\u975e\u540c\u671f\u30a4\u30f3\u30e9\u30a4\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u304c\u5b9f\u884c\u3055\u308c\u307e\u3057\u305f\")&lt;\/script&gt;\n\n\n&lt;script src=\"script1.js\"&gt;&lt;\/script&gt;\n\n&lt;script async src=\"script2.js\"&gt;&lt;\/script&gt;\n\n\n\n&lt;!-- Google \u30a2\u30c9\u30bb\u30f3\u30b9\u3000\u540c\u671f --&gt;\n&lt;script type=\"text\/javascript\"&gt;\nconsole.log(\"%c%s\",\n            \"color: red; background: yellow; font-size: 24px;\",\n            \"\u540c\u671fGoogle\u30a2\u30c9\u30bb\u30f3\u30b9\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u307e\u3057\u305f\");\n    google_ad_client = \"ca-pub-4060928622734418\";\n    google_ad_slot = \"3545706206\";\n    google_ad_width = 336;\n    google_ad_height = 280;\n&lt;\/script&gt;\n&lt;script type=\"text\/javascript\"\nsrc=\"\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\"&gt;\n&lt;\/script&gt;\n\n\n\n&lt;!-- Google \u30a2\u30c9\u30bb\u30f3\u30b9\u3000\u975e\u540c\u671f --&gt;\n&lt;script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"&gt;&lt;\/script&gt;\n&lt;ins class=\"adsbygoogle\"\n     style=\"display:inline-block;width:336px;height:280px\"\n     data-ad-client=\"ca-pub-4060928622734418\"\n     data-ad-slot=\"3545706206\"&gt;&lt;\/ins&gt;\n&lt;script&gt;\nconsole.log(\"%c%s\",\n            \"color: red; background: yellow; font-size: 24px;\",\n            \"\u975e\u540c\u671fGoogle\u30a2\u30c9\u30bb\u30f3\u30b9\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u307e\u3057\u305f\");\n(adsbygoogle = window.adsbygoogle || []).push({});\n&lt;\/script&gt;\n\n\n&lt;!-- Global \u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9--&gt;\n&lt;script async src=\"https:\/\/www.googletagmanager.com\/gtag\/js?id=UA-27276322-1\"&gt;&lt;\/script&gt;\n&lt;script&gt;\nconsole.log(\"%c%s\",\n            \"color: red; background: yellow; font-size: 24px;\",\n            \"Google\u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u307e\u3057\u305f\");\n  window.dataLayer = window.dataLayer || [];\n  function gtag(){dataLayer.push(arguments);}\n  gtag('js', new Date());\n\n  gtag('config', 'UA-27276322-1');\n&lt;\/script&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u691c\u8a3c\u7d50\u679c<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>Chrome\u306f\u6982\u306d\u72d9\u3044\u901a\u308a\u306b\u52d5\u3044\u3066\u3044\u308b\u3002<\/li><li>Safari\u306f\u3001\u30a2\u30c9\u30bb\u30f3\u30b9\u306e\u30b3\u30fc\u30c9\u304c\u300c\u505c\u6b62\u300d\u306f\u3067\u304d\u308b\u304c\u3001\u300c\u518d\u5b9f\u884c\u300d\u3067\u304d\u306a\u3044\u3063\u307d\u304f\u3066\u300cOK\u300d\u304c\u62bc\u3055\u308c\u3066\u3082\u5e83\u544a\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u3002<\/li><li>Firefox\u306f\u3001\u307e\u3063\u305f\u304f\u505c\u6b62\u3067\u304d\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u65b9\u6cd5\u3067\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5236\u5fa1\u3067\u304d\u306a\u3044\u3002<\/li><li>IE, Edge\u306f\u8a66\u3057\u3066\u3044\u306a\u3044\u3002<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u30b5\u30a4\u30c8\u4e0a\u3067\u5b9f\u884c\u3055\u308c\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3064\u3044\u3066\u540c\u610f\u3092\u78ba\u8a8d&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6115,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=6117"}],"version-history":[{"count":1,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6117\/revisions"}],"predecessor-version":[{"id":7909,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/6117\/revisions\/7909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/6115"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=6117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=6117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=6117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}