Changeset 18597 for lang/javascript/userscripts
- Timestamp:
- 09/02/08 00:06:54 (3 months ago)
- Files:
-
- 1 modified
-
lang/javascript/userscripts/poptip.user.js (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/userscripts/poptip.user.js
r18591 r18597 28 28 Add 2 rules to SITEINFO (Slashdot.org, YouTube in Hatena Bookmark) 29 29 20080824 0.0.9 "excludeUrl" option 30 Add 2 rules to SITEINFO (Yahoo Chiebukuro, Hatena Keyword)30 Add 2 rules to SITEINFO (Yahoo! Chiebukuro, Hatena Keyword) 31 31 */ 32 32 … … 46 46 var SITEINFO = [ 47 47 { 48 url: '^http://mixi\\.jp/ *',48 url: '^http://mixi\\.jp/', 49 49 linkElement: 'id("mymixiList")//td/a', 50 50 popupElement: 'id("profile")', 51 51 disabled: false, 52 style : { 53 backgroundColor : 'white', 54 borderWidth : '1px', 55 borderColor: 'orange', 56 borderStyle: 'solid' 57 } 58 }, 59 { 60 url: '^http://mixi\\.jp/*', 52 style: { 53 backgroundColor: 'white', 54 border: '1px solid orange' 55 } 56 }, 57 { 58 url: '^http://mixi\\.jp/', 61 59 targetElement: 'id("myProfile")//div[@class="contents01"]/img', 62 60 linkElement: 'id("myProfile")//div[@class="contents03"]//a', 63 61 popupElement: 'id("editPhotoArea")', 64 62 disabled: false, 65 style : { 66 backgroundColor : 'white', 67 borderWidth : '1px', 68 borderColor: 'orange', 69 borderStyle: 'solid' 63 style: { 64 backgroundColor: 'white', 65 border: '1px solid orange' 70 66 } 71 67 }, 72 68 { 73 69 description: 'mixi community recent topics', 74 url: '^http://mixi\\.jp/ *',70 url: '^http://mixi\\.jp/', 75 71 linkElement: 'id("communityList")//td/a', 76 72 popupElement: 'id("newCommunityTopic")//dl', 77 style : { 78 backgroundColor : 'white', 79 borderWidth : '1px', 80 padding : '8px', 81 borderColor: 'orange', 82 borderStyle: 'solid' 73 style: { 74 backgroundColor: 'white', 75 border: '1px solid orange', 76 padding: '8px' 83 77 }, 84 78 containerHTML: '<h2>Recent Topics</h2><popup:container/>' … … 89 83 linkElement: 'id("log_color")/ul/li/a', 90 84 popupElement: 'id("profile")', 91 style : {92 border: " solid 1pxgray",85 style: { 86 border: "1px solid gray", 93 87 width: "400px" 94 88 } 95 89 }, 96 90 { 97 url: '^http://( www|)flickr\\.com/.*',91 url: '^http://(?:www\\.)?flickr\\.com/', 98 92 linkElement: '//span[@class="photo_container pc_s"]/a', 99 93 popupElement: '//div[@class="photoImgDiv"]//img', 100 style : {94 style: { 101 95 padding: '0px' 102 96 } … … 104 98 { 105 99 descript: 'Flickr Exif info', 106 url: '^http://( www|)flickr\\.com/.*',100 url: '^http://(?:www\\.)?flickr\\.com/', 107 101 linkElement: '//li[@class="Stats"]/a[.="More properties"]', 108 102 popupElement: 'id("GoodStuff")', 109 103 stripe: true, 110 style : {111 backgroundColor : 'white',112 padding : '4px;',113 margin : '4px;',114 border : 'solid 1px#444'115 } 116 }, 117 { 118 url: '^http://( www|)flickr\\.com/.*',104 style: { 105 backgroundColor: 'white', 106 padding: '4px;', 107 margin: '4px;', 108 border: '1px solid #444' 109 } 110 }, 111 { 112 url: '^http://(?:www\\.)?flickr\\.com/', 119 113 linkElement: '//span[@class="photo_container pc_s"]/a', 120 114 popupElement: '//div[@class="photoImgDiv"]//img', 121 style : {122 backgroundColor : 'white'115 style: { 116 backgroundColor: 'white' 123 117 } 124 118 }, … … 129 123 linkElement: '//div[@class="inner"]/ul/li/nobr/a', 130 124 popupElement: '//div[@class="inner"]/ul', 131 stripe: true,125 stripe: true, 132 126 style: { 133 127 fontSize: '80%', 134 128 textAlign: 'left', 135 padding : '4px;',136 margin : '4px;',137 border : 'solid 1px#444'129 padding: '4px;', 130 margin: '4px;', 131 border: '1px solid #444' 138 132 } 139 133 }, 140 134 { 141 135 description: 'Hatena Bookmark', 142 url: '^http://b\\.hatena\\.ne\\.jp/ *',136 url: '^http://b\\.hatena\\.ne\\.jp/', 143 137 linkElement: '//div[@class="entry-footer"]//*//a', 144 138 popupElement: 'id("entry-info")//blockquote', 145 139 delay: 1000, 146 stripe: true,140 stripe: true, 147 141 style: { 148 142 fontSize: '80%' … … 151 145 { 152 146 description: 'Hatena Bookmark', 153 url: '^http://b\\.hatena\\.ne\\.jp/ *',147 url: '^http://b\\.hatena\\.ne\\.jp/', 154 148 linkElement: '//dd[@class="users"]//a', 155 149 popupElement: 'id("entry-info")//blockquote', … … 157 151 style: { 158 152 fontSize: '80%', 159 border: ' solid 1pxblue'153 border: '1px solid blue' 160 154 } 161 155 }, 162 156 { 163 157 description: 'Hatena Diary Keyword', 164 url: '^http://d\\.hatena\\.ne\\.jp/ *',165 excludeUrl: '^http://d\\.hatena\\.ne\\.jp/keyword/ .*',158 url: '^http://d\\.hatena\\.ne\\.jp/', 159 excludeUrl: '^http://d\\.hatena\\.ne\\.jp/keyword/', 166 160 linkElement: '//a[@class="keyword"]', 167 161 popupElement: '//div[@class="box-curve-bar"]//div[@class="section"]', 168 162 delay: 1000, 169 stripe: true,163 stripe: true, 170 164 style: { 171 165 fontSize: '80%', 172 166 padding: '2px', 173 border: ' solid 1pxblue',167 border: '1px solid blue', 174 168 color: 'black', 175 169 backgroundColor: 'white', … … 179 173 { 180 174 description: 'Hatena Keyword', 181 url: '^http://d\\.hatena\\.ne\\.jp/keyword/ .*',175 url: '^http://d\\.hatena\\.ne\\.jp/keyword/', 182 176 linkElement: '//a[@class="keyword"]', 183 177 popupElement: 'id("body")//div[@class="keyword-body"]/div[@class="section"]/p', 184 178 delay: 1000, 185 stripe: true,179 stripe: true, 186 180 style: { 187 181 fontSize: '80%', 188 182 padding: '2px', 189 border: ' solid 1pxblue',183 border: '1px solid blue', 190 184 color: 'black', 191 185 backgroundColor: 'white', … … 194 188 }, 195 189 { 196 url: '^http://mixi\\.jp/( search|list)_community\\.pl.*',190 url: '^http://mixi\\.jp/(?:search|list)_community\\.pl', 197 191 linkElement: '//div[@class="iconList03"]//a', 198 192 popupElement: 'id("newCommunityTopic")//dl', 199 style : { 200 backgroundColor : 'white', 201 borderWidth : '1px', 202 padding : '8px', 203 borderColor: 'orange', 204 borderStyle: 'solid' 205 } 206 }, 207 { 208 description: 'Yahoo Chiebukuro related question', 193 style: { 194 backgroundColor: 'white', 195 border: '1px solid orange', 196 padding: '8px' 197 } 198 }, 199 { 200 description: 'Yahoo! Chiebukuro related question', 209 201 url: '^http://detail\\.chiebukuro\\.yahoo\\.co\\.jp/qa/question_detail/.+', 210 202 linkElement: 'id("recommend")//dd[@class="recombox"]/a', 211 203 popupElement: '//div[@class="bestAnswer Extends-details"]//div[@class="qa"]', 212 style : { 213 backgroundColor : 'white', 214 borderWidth : '1px', 215 padding : '8px', 216 borderColor: 'blue', 217 fontSize: '80%', 218 textAlign: 'left', 219 borderStyle: 'solid' 204 style: { 205 backgroundColor: 'white', 206 borderWidth: '1px solid blue', 207 padding: '8px', 208 fontSize: '80%', 209 textAlign: 'left' 220 210 }, 221 211 containerHTML: '<h2>Best Answer</h2><popup:container/>' 222 212 }, 223 224 213 { 225 214 description: 'Twitter icon enlargement', 226 url: '^http://twitter\\.com/ *',215 url: '^http://twitter\\.com/', 227 216 targetElement: '//td[@class="thumb vcard author"]//img[@class="photo fn"]', 228 linkElement: '//td[@class="thumb vcard author"]//a[@class="url"]',217 linkElement: '//td[@class="thumb vcard author"]//a[@class="url"]', 229 218 linkReplaceRule: { 230 pattern : 'http://twitter.com/',231 replacement : 'http://twitter.com/account/profile_image/'219 pattern: 'http://twitter.com/', 220 replacement: 'http://twitter.com/account/profile_image/' 232 221 }, 233 222 popupElement: 'id("content")/div/p/img', … … 235 224 { 236 225 description: 'Twitter timeline', 237 url: '^http://twitter\\.com/ *',238 linkElement: 'id("content")//td[@class="content"]/strong/a',226 url: '^http://twitter\\.com/', 227 linkElement: 'id("content")//td[@class="content"]/strong/a', 239 228 popupElement: 'id("side")', 240 229 disabled: true, … … 246 235 { 247 236 description: 'Twitter following & followers', 248 url: '^http://twitter\\.com .*/(friends|followers)',237 url: '^http://twitter\\.com/.+?/(?:friends|followers)', 249 238 targetElement: '//td[@class="thumb"]//img[@class="photo fn"]', 250 linkElement: '//td[@class="thumb"]//a[@rel="contact"]',239 linkElement: '//td[@class="thumb"]//a[@rel="contact"]', 251 240 popupElement: 'id("side")', 252 241 style: { … … 257 246 { 258 247 description: 'Hatena Fotolife', 259 url: '^http://f\\.hatena\\.ne\\.jp/ .*',248 url: '^http://f\\.hatena\\.ne\\.jp/', 260 249 linkElement: '//ul[@class="fotolist"]/li/a', 261 250 popupElement: 'id("container")/div[2]/div[3]/img', 262 style : {251 style: { 263 252 } 264 253 }, 265 254 { 266 255 description: 'Pixiv thumbnails', 267 url: '^http://www\\.pixiv\\.net/tags\\.php\\?tag= .*',256 url: '^http://www\\.pixiv\\.net/tags\\.php\\?tag=', 268 257 linkElement: 'id("illust_c5")/ul/li/a[1]', 269 258 popupElement: 'id("content2")/div[6]/a/img', 270 style : {271 border : 'solid 1pxblack'259 style: { 260 border: '1px solid black' 272 261 } 273 262 }, 274 263 { 275 264 description: 'Amazon.co.jp ListMania', 276 url: '^http://www\\.amazon\\.co\\.jp/. */lm/.*',265 url: '^http://www\\.amazon\\.co\\.jp/.+?/lm/', 277 266 targetElement: '//td[@class="listItem"]/a/img[position()=1]', 278 linkElement: '//td[@class="listItem"]//strong/a',267 linkElement: '//td[@class="listItem"]//strong/a', 279 268 popupElement: 'id("productDescription")', 280 269 stripe: true, 281 style : {282 fontSize : '80%',283 width : '500px',284 padding : '5px',285 border : 'solid 1pxorange'270 style: { 271 fontSize: '80%', 272 width: '500px', 273 padding: '5px', 274 border: '1px solid orange' 286 275 } 287 276 }, 288 277 { 289 278 description: 'Amazon.co.jp SearchResult', 290 url: '^http://www\\.amazon\\.co\\.jp/s/ .*',291 linkElement: '//td[@class="imageColumn"]//a',279 url: '^http://www\\.amazon\\.co\\.jp/s/', 280 linkElement: '//td[@class="imageColumn"]//a', 292 281 popupElement: 'id("productDescription")', 293 282 delay: 300, 294 283 stripe: true, 295 style : {296 fontSize : '80%',297 width : '500px',298 padding : '5px',299 border : 'solid 1pxorange'284 style: { 285 fontSize: '80%', 286 width: '500px', 287 padding: '5px', 288 border: '1px solid orange' 300 289 } 301 290 }, 302 291 { 303 292 description: 'slashdot.jp recent 3 stories', 304 url: '^http://slashdot\\.( jp|org)/topics\\.(pl|shtml)',293 url: '^http://slashdot\\.(?:jp|org)/topics\\.(?:pl|shtml)', 305 294 exampleUrl: 'http://slashdot.jp/topics.pl', 306 295 targetElement: '//div[@class="generalbody"]/table//td[@align="center"]/a/img', 307 296 linkElement: '//div[@class="generalbody"]/table//td[@align="center"]/a', 308 297 popupElement: '//div[@class="search-results"][position()<4]', 309 style : {310 border : 'solid 1pxblack',311 padding : '4px',312 fontSize : '80%'298 style: { 299 border: '1px solid black', 300 padding: '4px', 301 fontSize: '80%' 313 302 } 314 303 }, 315 304 { 316 305 description: 'Youtube in Hatena Bookmark', 317 url: '^http://b\\.hatena\\.ne\\.jp/ .*',306 url: '^http://b\\.hatena\\.ne\\.jp/', 318 307 linkElement: '//a[contains(@href,"youtube.com/") and contains(text(),"users")]', 319 308 popupElement: 'id("video")', … … 348 337 // Right 349 338 popupAreaObj.style.left = targetDimension.left + targetDimension.width + 'px'; 350 popupAreaObj.style.top = targetDimension.top + 'px';339 popupAreaObj.style.top = targetDimension.top + 'px'; 351 340 var dimension = getDimension(this); 352 341 if (dimension.width > targetDimension.offsetRight) popupAreaObj.style.width = targetDimension.offsetRight + 'px'; … … 371 360 if (popupAreaObj._currentTarget == target) this.style.display = 'none'; 372 361 }; 373 popupAreaObj.append = function (elm) {362 popupAreaObj.append = function(elm) { 374 363 while (this.childNodes.length > 0) this.removeChild(this.firstChild); 375 364 this.appendChild(elm); 376 } 365 }; 377 366 popupAreaObj._currentTarget = null; 378 367 379 function PopupManager () {380 this.init = function () {368 function PopupManager() { 369 this.init = function() { 381 370 document.body.appendChild(popupAreaObj); 382 371 this.maxZIndex = 0; … … 388 377 } 389 378 } 390 popupAreaObj.style.zIndex = this.maxZIndex + 2;379 popupAreaObj.style.zIndex = this.maxZIndex + 2; 391 380 392 381 for (var i in SITEINFO) { 393 382 if (SITEINFO[i].disabled) continue; 394 if (!location.href.match(new RegExp(SITEINFO[i].url)) || (SITEINFO[i].excludeUrl && location.href.match(new RegExp(SITEINFO[i].excludeUrl)))) continue; 383 if (!location.href.match(new RegExp(SITEINFO[i].url)) || (SITEINFO[i].excludeUrl && location.href.match(new RegExp(SITEINFO[i].excludeUrl)))) continue; 395 384 var targetElementList = getElementsByXPath((SITEINFO[i].targetElement)?SITEINFO[i].targetElement:SITEINFO[i].linkElement); 396 385 var linkElementList = getElementsByXPath(SITEINFO[i].linkElement); … … 409 398 if (rule.pattern && rule.replacement) url = url.replace(new RegExp(rule.pattern), rule.replacement); 410 399 } 411 this.setEvent (targetElementList[j], url, SITEINFO[i].popupElement, 400 this.setEvent (targetElementList[j], url, SITEINFO[i].popupElement, 412 401 { 413 402 style:SITEINFO[i].style, … … 427 416 targetElement.lock = function() { 428 417 targetElement._locked = true; 429 } 418 }; 430 419 targetElement.unlock = function(e) { 431 420 targetElement._locked = false; 432 421 if (targetElement._mouseOut) targetElement.removePopupElement(); 433 } 422 }; 434 423 435 424 targetElement.removePopupElement = function() { 436 setTimeout(function () {425 setTimeout(function() { 437 426 if (!targetElement._mouseOut) return; 438 427 if (!targetElement._locked) popupAreaObj.hide(targetElement); 439 428 }, HIDE_DELAY_MSEC); 440 441 } 442 targetElement.addPopupElement = function () {429 430 }; 431 targetElement.addPopupElement = function() { 443 432 if (targetElement._elementCache != null) { 444 433 popupAreaObj.append(targetElement._elementCache); … … 462 451 } 463 452 } 464 if (option.containerHTML) {453 if (option.containerHTML) { 465 454 elmContainer.innerHTML = option.containerHTML; 466 455 var tmpList = elmContainer.getElementsByTagName('popup:container'); … … 470 459 } 471 460 } 472 } else {461 } else { 473 462 for (var elementIndex in elementList) { 474 463 elmContainer.appendChild(elementList[elementIndex]); 475 464 } 476 }465 } 477 466 targetElement._elementCache = elmContainer; 478 467 elmContainer.addEventListener('mouseover', targetElement.lock, true); … … 482 471 } catch (ex) {} 483 472 } 484 } 473 }; 485 474 http.send(null); 486 475 }; 487 476 targetElement.addEventListener ('mouseout', 488 function() {477 function() { 489 478 try { 490 479 targetElement._mouseOut = true; 491 480 targetElement.removePopupElement(); 492 } catch (ex) {}481 } catch (ex) {} 493 482 }, 494 483 true); 495 484 496 485 targetElement.addEventListener ('mouseover', 497 function() {486 function() { 498 487 targetElement._mouseOut = false; 499 setTimeout(function () {488 setTimeout(function() { 500 489 if (targetElement._mouseOut) return; 501 490 targetElement.addPopupElement(); … … 503 492 }, 504 493 true); 505 } 494 }; 506 495 } 507 496 508 497 (new PopupManager()).init(); 509 498 510 function DimensionInfo (left, top, width, height) {499 function DimensionInfo(left, top, width, height) { 511 500 this.top = top; 512 501 this.left = left; … … 530 519 var dimension; 531 520 if (elm) { 532 dimension = new DimensionInfo(elm.offsetLeft, elm.offsetTop,elm.offsetWidth,elm.offsetHeight);521 dimension = new DimensionInfo(elm.offsetLeft, elm.offsetTop, elm.offsetWidth, elm.offsetHeight); 533 522 if (elm.offsetParent ) { 534 523 tmp = _getDimension(elm.offsetParent); … … 545 534 546 535 function createHTMLDocumentByString(str) { 547 var html = str.replace(/<!DOCTYPE .*?>/, '').replace(/<html.*?>/, '').replace(/<\/html>.*/, '')548 var htmlDoc = document.implementation.createDocument(null, 'html', null) 549 var fragment = createDocumentFragmentByString(html) 536 var html = str.replace(/<!DOCTYPE\s[^>]+>|<html(?:\s[^>]*)?>|<\/html\s*>.*/, ''); 537 var htmlDoc = document.implementation.createDocument(null, 'html', null); 538 var fragment = createDocumentFragmentByString(html); 550 539 try { 551 fragment = htmlDoc.adoptNode(fragment) 552 } catch (e) {553 fragment = htmlDoc.importNode(fragment, true) 554 } 555 htmlDoc.documentElement.appendChild(fragment) 556 return htmlDoc540 fragment = htmlDoc.adoptNode(fragment); 541 } catch (e) { 542 fragment = htmlDoc.importNode(fragment, true); 543 } 544 htmlDoc.documentElement.appendChild(fragment); 545 return htmlDoc; 557 546 } 558 547 559 548 function createDocumentFragmentByString(str) { 560 var range = document.createRange() 561 range.setStartAfter(document.body) 562 return range.createContextualFragment(str) 549 var range = document.createRange(); 550 range.setStartAfter(document.body); 551 return range.createContextualFragment(str); 563 552 } 564 553 565 554 function getElementsByXPath(xpath, node) { 566 var node = node || document 567 var doc = node.ownerDocument ? node.ownerDocument : node 555 var node = node || document; 556 var doc = node.ownerDocument ? node.ownerDocument : node; 568 557 var nodesSnapshot = doc.evaluate(xpath, node, null, 569 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) 570 var data = [] 571 for (var i = 0 ; i < nodesSnapshot.snapshotLength; i++) {572 data.push(nodesSnapshot.snapshotItem(i)) 573 } 574 return data 575 } 558 XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 559 var data = []; 560 for (var i = 0, l = nodesSnapshot.snapshotLength; i < l; i++) { 561 data.push(nodesSnapshot.snapshotItem(i)); 562 } 563 return data; 564 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)