-
Notifications
You must be signed in to change notification settings - Fork 0
/
longteng_original_title.js
33 lines (26 loc) · 1.31 KB
/
longteng_original_title.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// ==UserScript==
// @name 获取并搜索龙腾网文章原始标题
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description 复制并使用 google 搜索龙腾网原始文章标题
// @author [email protected]
// @match https://translate.ltaaa.cn/article/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @downloadURL https://update.greasyfork.org/scripts/482768/%E5%A4%8D%E5%88%B6%E9%BE%99%E8%85%BE%E7%BD%91%E6%96%87%E7%AB%A0%E6%A0%87%E9%A2%98.user.js
// @updateURL https://update.greasyfork.org/scripts/482768/%E5%A4%8D%E5%88%B6%E9%BE%99%E8%85%BE%E7%BD%91%E6%96%87%E7%AB%A0%E6%A0%87%E9%A2%98.meta.js
// ==/UserScript==
(function() {
'use strict';
// 获取原文标题
var remarkText = document.querySelector('.remark').innerHTML;
// 提取原文标题后到<br>前的文字
var startIndex = remarkText.indexOf('原文标题:') + '原文标题:'.length;
var endIndex = remarkText.indexOf('<br>');
var originalTitle = remarkText.substring(startIndex, endIndex).trim();
// 输出原文标题
console.log('getOriginalTitle:' + originalTitle);
// 使用google 搜索标题
var url = 'https://www.google.com/search?q='+ originalTitle;
window.open(url, '_blank');
})();