Skip to content

Instantly share code, notes, and snippets.

@sakama
Last active August 29, 2015 14:07
Show Gist options
  • Save sakama/7e5bd4893a6e7b053a22 to your computer and use it in GitHub Desktop.
Save sakama/7e5bd4893a6e7b053a22 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name My Fancy New Userscript
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match http://www.yahoo.co.jp/*
// @grant none
// ==/UserScript==
// 現在閲覧中のドメインを取得
var domain = document.domain;
// DOMエレメント生成
alertElement = document.createElement('div');
alertElement.innerHTML = '<div style="background:#ff0000; padding:10px;">Yahoo見てないで仕事しろ!!</div>';
//閲覧中のページ内の最初の<div>タグを取得
divTags = document.getElementsByTagName('div');
firstDivTag = divTags[0];
// 閲覧中のページがhttp://www.yahoo.co.jp/*配下の場合は
// ページの最初の<div>タグの前に警告用の<div>タグを追加する
if(domain=='www.yahoo.co.jp') {
document.body.insertBefore(alertElement, firstDivTag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment