読者です 読者をやめる 読者になる 読者になる

01647

ustreamer-01647

navigator.userAgent偽装準備

無料動画 GyaO!Linuxでも利用したい.

GyaO!「使い方ガイド」をご利用いただくには、以下の環境が必要です。

f:id:paulga:20131028105828p:plain

Yahoo! JAPAN ヘルプセンター

Chromium on Lubuntu 13.10では,OSが不明とされ,利用できない.世に出ているUserAgent詐称コードはHTTPヘッダ情報をのみ書き換える.GyaO!javascriptのnavigator.userAgentを参照するため,効果が無い.

Firefoxでは別途UAを詐称した上でUser-Agent JS Fixer :: Add-ons for Firefoxを適用することでクリアできるようだ.

OperaSilverlightをインストールした上でuserscriptを導入し,打開していたようだ.kyu3 - OperaでGyao!を見られるようにするUser JSを追加.今では標準で回避策が用意されているようだ.GyaOを観たい - Opera Wiki.(Windowsの話じゃん)

Chromiumでの視聴を諦め,「Firefox+UA詐称+User-Agent JS Fixer」が正解な気がしてきた.

bootstrap.js

  • バージョン番号:1.3
  • 作者:BlinD-HuNTeR
  • 更新日:July 2, 2013
const Ci = Components.interfaces;
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);

function onDocumentCreated(aSubject, aTopic, aData)
{
	aSubject = aSubject.defaultView; if (aSubject)
	var aChannel = aSubject.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell).currentDocumentChannel;
	if (aChannel instanceof Ci.nsIHttpChannel)
	{
		var navigator = aSubject.navigator;
		try { var userAgent = aChannel.getRequestHeader("User-Agent"); } catch (e) {}
		if (navigator.userAgent != userAgent) Object.defineProperty(XPCNativeWrapper.unwrap(navigator), "userAgent", {value : userAgent, enumerable : true});
	}
}

function startup(data, aReason) { observerService.addObserver(onDocumentCreated, "document-element-inserted", false); }
function shutdown(data, aReason) { observerService.removeObserver(onDocumentCreated, "document-element-inserted"); }
function install(data, aReason) {}
function uninstall(data, aReason) {}
User-Agent JS Fixer :: Add-ons for Firefox

86250.user.js

  • バージョン番号:0.3
  • 作者:sweetmagic
  • 更新日:Oct 4, 2010
  • 86250.user.js
// ==UserScript==
// @name   OperaFix GyaoYahooDouga 
// @version 0.3
// @description Version 0.3 (OperaFixギャオヤフー)
// @namespace OperaFix GyaoYahoo (cc) http://creativecommons.org/licenses/by-nc/2.1/jp/deed.ja
// @author  Kurojitosan (SpecialThanks hogehoge)
// @include http://player.gyao.yahoo.co.jp/*
// @include http://gyao.yahoo.co.jp/*
// @include http://*.yahoo.co.jp/*
// @exclude http://acid3.acidtests.org/* 
// ==/UserScript==
                            
	if(0<=navigator.userAgent.indexOf('Opera')){
		if(location.hostname=='gyao.yahoo.co.jp') {
			window.opera.defineMagicFunction('isCommonEnvCheck',function(){return(true);});
 			window.opera.defineMagicFunction('isNormalPlayerCheck',function(){return(true);});
		}
	}
Source for "OperaFix GyaoYahooDouga" - Userscripts.org

env-min.js

http://i.yimg.jp/images/help/env/1.2.1/env-min.jsOnline JavaScript beautifierで整形した.

// env-min.js 1.2.1
/*
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
*/
if (typeof YAHOO == "undefined" || !YAHOO) {
    var YAHOO = {}
}
YAHOO.namespace = function () {
    var b = arguments,
        g = null,
        e, c, f;
    for (e = 0; e < b.length; e = e + 1) {
        f = b[e].split(".");
        g = YAHOO;
        for (c = (f[0] == "YAHOO") ? 1 : 0; c < f.length; c = c + 1) {
            g[f[c]] = g[f[c]] || {};
            g = g[f[c]]
        }
    }
    return g
};
YAHOO.namespace("JP.lib.env");
YAHOO.JP.lib.env = window.YAHOO.JP.lib.env = {
    os: {
        name: decodeURI("%E4%B8%8D%E6%98%8E"),
        code: "na"
    },
    browser: {
        name: decodeURI("%E4%B8%8D%E6%98%8E"),
        version: 0,
        code: "na"
    },
    flash: {
        isInstall: false,
        version: 0
    },
    wmp: {
        isInstall: false,
        version: 0
    },
    activex: {
        enable: false
    }
};
(function () {
    var ENV = YAHOO.JP.lib.env;
    var xLBua = navigator.userAgent;
    var xLBdcap = document.all;
    var xLBlcap = document.layers;
    var xLBgcap = document.getElementById;
    var xLBopr = window.opera;
    if (!xLBdcap && xLBgcap && !xLBopr) {
        if (xLBua.indexOf("Netscape6") !== -1 || xLBua.indexOf("Netscape/7") !== -1) {
            ENV.browser.name = "Netscape Navigator";
            xLBtmp = xLBua.split("/");
            xLBtmpc = xLBtmp[3].split(" ");
            ENV.browser.version = parseFloat(xLBtmpc[0]);
            ENV.browser.code = "ns6"
        } else {
            if (xLBua.indexOf("Chrome/") !== -1) {
                ENV.browser.name = "Google Chrome";
                ENV.browser.code = "chrome";
                ENV.browser.version = parseFloat(xLBua.split("Chrome/")[1].split(" ")[0])
            } else {
                if (xLBua.indexOf("KHTML") !== -1) {
                    ENV.browser.name = "Safari";
                    ENV.browser.code = "safari";
                    xLBtmp = xLBua.split("/");
                    xLBtmpc = xLBtmp[2].split(" ");
                    ENV.browser.version = parseFloat(xLBtmpc[0]);
                    if (ENV.browser.version >= 525) {
                        xLBtmp = xLBua.split("Version/")[1].split(" ")[0];
                        ENV.browser.version = xLBtmp.split(".")[0] + "." + xLBtmp.split(".")[1]
                    } else {
                        if (ENV.browser.version >= 520) {
                            ENV.browser.version = "3.0"
                        } else {
                            if (ENV.browser.version >= 412) {
                                ENV.browser.version = "2.0"
                            } else {
                                if (ENV.browser.version >= 312) {
                                    ENV.browser.version = "1.3"
                                } else {
                                    if (ENV.browser.version >= 125) {
                                        ENV.browser.version = "1.2"
                                    } else {
                                        if (ENV.browser.version >= 100) {
                                            ENV.browser.version = "1.1"
                                        } else {
                                            if (ENV.browser.version >= 85) {
                                                ENV.browser.version = "1.0"
                                            } else {
                                                ENV.browser.version = ""
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if (xLBua.indexOf("Firefox") !== -1) {
                        ENV.browser.name = "Firefox";
                        ENV.browser.code = "mozilla";
                        xLBtmp = xLBua.split("Firefox/");
                        xLBtmpc = xLBtmp[1].split(" ");
                        ENV.browser.version = parseFloat(xLBtmpc[0])
                    } else {
                        ENV.browser.name = decodeURI("%E3%81%9D%E3%81%AE%E4%BB%96%E3%83%96%E3%83%A9%E3%82%A6%E3%82%B6");
                        ENV.browser.code = "other";
                        ENV.browser.version = ""
                    }
                }
            }
        }
    }
    if (xLBlcap) {
        ENV.browser.name = "Netscape Navigator";
        xLBtmp = xLBua.split("/");
        xLBtmpc = xLBtmp[1].split(" ");
        ENV.browser.version = parseFloat(xLBtmpc[0]);
        ENV.browser.code = "ns4"
    }
    if (xLBdcap && xLBgcap && !xLBopr) {
        ENV.browser.name = "Internet Explorer";
        xLBtmp = xLBua.split("MSIE ");
        xLBtmpc = xLBtmp[1].split(";");
        ENV.browser.version = parseFloat(xLBtmpc[0]);
        ENV.browser.code = "ie5"
    }
    if (xLBdcap && !xLBgcap) {
        ENV.browser.name = "Internet Explorer";
        xLBtmp = xLBua.split("MSIE ");
        xLBtmpc = xLBtmp[1].split(";");
        ENV.browser.version = parseFloat(xLBtmpc[0]);
        ENV.browser.code = "ie4"
    }
    if (xLBopr) {
        ENV.browser.name = "Opera";
        ENV.browser.code = "opera";
        ENV.browser.version = ""
    }
    if (xLBua.indexOf("Win") !== -1) {
        if (xLBua.indexOf("95") !== -1) {
            ENV.os.code = "win95";
            ENV.os.name = "Windows 95"
        }
        if (xLBua.indexOf("98") !== -1) {
            ENV.os.code = "win98";
            ENV.os.name = "Windows 98"
        }
        if (xLBua.indexOf("4.90") !== -1) {
            ENV.os.code = "win98";
            ENV.os.name = "Windows ME"
        }
        if (xLBua.indexOf("NT 4.0") !== -1) {
            ENV.os.code = "winNT4";
            ENV.os.name = "Windows NT 4.0"
        }
        if (xLBua.indexOf("NT 5.0") !== -1) {
            ENV.os.code = "winNT5";
            ENV.os.name = "Windows 2000"
        }
        if (xLBua.indexOf("NT 5.1") !== -1) {
            ENV.os.code = "winNT5";
            ENV.os.name = "Windows XP"
        }
        if (xLBua.indexOf("SV1") !== -1) {
            ENV.os.code = "winNT5s";
            ENV.os.name = "Windows XP SP2, SP3"
        }
        if (xLBua.indexOf("IEMB3") !== -1) {
            ENV.os.code = "winNT5s";
            ENV.os.name = "Windows XP SP2, SP3"
        }
        if (xLBua.indexOf("NT 5.1") !== -1 && xLBua.indexOf("MSIE 7") !== -1) {
            ENV.os.code = "winNT5s";
            ENV.os.name = "Windows XP SP2, SP3"
        }
        if (xLBua.indexOf("NT 5.1") !== -1 && xLBua.indexOf("MSIE 8") !== -1) {
            ENV.os.code = "winNT5s";
            ENV.os.name = "Windows XP SP2, SP3"
        }
        if (xLBua.indexOf("NT 5.2") !== -1) {
            ENV.os.code = "winNT5.2";
            ENV.os.name = "Windows Server 2003, Windows XP x64 Edition"
        }
        if (xLBua.indexOf("NT 6.0") !== -1) {
            ENV.os.code = "winNT6";
            ENV.os.name = "Windows Vista"
        }
        if (xLBua.indexOf("NT 6.0") !== -1 && (xLBua.indexOf("Win64") !== -1 || xLBua.indexOf("IA64") !== -1 || xLBua.indexOf("x64") !== -1)) {
            ENV.os.code = "winNT6";
            ENV.os.name = "Windows Vista x64 Edition"
        }
        if (xLBua.indexOf("NT 6.1") !== -1) {
            ENV.os.code = "winNT6.1";
            ENV.os.name = "Windows 7"
        }
        if (xLBua.indexOf("NT 6.2") !== -1) {
            ENV.os.code = "winNT6.2";
            ENV.os.name = "Windows 8"
        }
    }
    if (xLBua.indexOf("Mac OS X") !== -1) {
        ENV.os.code = "mac";
        ENV.os.name = "Mac OS X"
    } else {
        if (xLBua.indexOf("Mac") !== -1) {
            ENV.os.code = "mac";
            ENV.os.name = "Mac OS"
        }
    }
    var wmplugin = (navigator.mimeTypes && navigator.mimeTypes["video/x-ms-asf"]) ? navigator.mimeTypes["video/x-ms-asf"].enabledPlugin : 0;
    var wmpObj7 = '<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="1" height="1" id="WMP7" viewastext></object> \n<script language="VBScript"> \non error resume next \nWMP7obj = (WMP7.URL = "") \n<\/script> \n';
    var wmpObj6 = '<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="1" height="1" id="WMP6" viewastext></object> \n<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="1" height="1" id="WMP7" viewastext></object> \n<script language="VBScript"> \non error resume next \nWMP6obj = (WMP6.FileName = "") \nWMP7obj = (WMP7.URL = "") \n<\/script> \n';
    if (wmplugin) {
        ENV.wmp.isInstall = true;
        ENV.wmp.version = -1
    } else {
        if (ENV.browser.code.indexOf("ie") !== -1 && ENV.os.code.indexOf("win") !== -1) {
            if (ENV.os.name.indexOf("Windows Vista") !== -1) {
                document.write(wmpObj7)
            } else {
                document.write(wmpObj6)
            }
            try {
                if (WMP7obj) {
                    ENV.activex.enable = true;
                    ENV.wmp.isInstall = true;
                    ENV.wmp.version = parseInt(WMP7.versionInfo, 10)
                } else {
                    if (WMP6obj) {
                        ENV.activex.enable = true;
                        ENV.wmp.isInstall = true;
                        ENV.wmp.version = 6
                    }
                }
            } catch (e) {}
        }
    } if (isNaN(ENV.wmp.version) || ENV.wmp.version === 0) {
        ENV.wmp.isInstall = false
    }
    var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    var yimg = window.location.protocol === "http:" ? "http://i.yimg.jp" : "https://s.yimg.jp";
    if (plugin) {
        ENV.flash.isInstall = true;
        var desc = plugin.description;
        ENV.flash.version = eval(desc.substring(desc.indexOf("Flash") + 6, desc.indexOf("Flash") + 9))
    } else {
        if (ENV.browser.code.indexOf("ie") !== -1 && ENV.os.code.indexOf("win") !== -1) {
            if (!ENV.flash.isInstall) {
                document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="5" height="5" id="swf" name="swf" viewastext style="display:none;"><param name="movie" value="' + yimg + '/images/help/env/void.swf"></object>');
                try {
                    ENV.flash.version = Math.floor(window.swf.FlashVersion() / 65536)
                } catch (e) {}
                if (!isNaN(ENV.flash.version)) {
                    ENV.flash.isInstall = true
                }
            }
        }
    } if (isNaN(ENV.flash.version) || ENV.flash.version === 0) {
        ENV.flash.isInstall = false
    }
})();

wakuworks/userAgent.test

  • 2011-08-23 23:39:15
  • navigator.userAgent は JS で書き換えられる
try {
    if (!Object.prototype.__defineGetter__ &&
        Object.defineProperty({}, "x", { get: function(){ return true } }).x
    ) {
        Object.defineProperty(Object.prototype, "__defineGetter__", {
            enumerable: false,
            configurable: true,
            value: function(name, func) {
                Object.defineProperty(this,name, {
                    get: func,
                    enumerable: true,
                    configurable: true
                });
            }
        });
        Object.defineProperty(Object.prototype, "__defineSetter__", {
            enumerable: false,
            configurable: true,
            value: function(name, func) {
                Object.defineProperty(this,name, {
                    set: func,
                    enumerable: true,
                    configurable: true
                });
            }
        });
    }
}
catch (defPropException) { /* Do nothing if an exception occurs */ }

var __original = navigator;
var navigator = {};
navigator.__proto__ = __original;

navigator.__defineGetter__
    ? navigator.__defineGetter__("userAgent", function () { return "foo"; })
    : navigator.userAgent = "foo";

document.write("navigator.userAgent = " + navigator.userAgent);
navigator.userAgent は当てにならないテスト - jsdo.it - Share JavaScript, HTML5 and CSS