You have been waiting for a long time, many friends asked “small assistant why not update the more activities in November?” Here it comes.

However, in addition to the follow-on activity, this release also brings a blockbuster update — the aggregation platform.

In version 1.0.0, Gold Mining Activity Assistant was upgraded to Gold Mining Extension Assistant, which is no longer a single function carrier, but an aggregation platform that aggregates scripts around the gold mining community in a single market, easily pluggable.

Let’s get right to it and see how it works.

Operating instruction

Install the Oil Monkey plugin, Tampermonkey • home page. Can’t download? Try using the Oilmonkey offline download package – Feishu Doc.

Visit the Nuggets Extension Assistant (greasyfork.org) to install the script.

The current version comes with a pre-installed “more text activity small assistant”. After installing the script, you can see the activity progress on your home page.

At the same time, you can access the “extended Market” through the Oilmonkey script portal.

Take a look at any extensions you need and add them.

Refresh the nuggets page to see the results.

The platform automatically checks for updates every day. If manual updates are needed, you can enter the extended market for updates.

How to mount the Oilmonkey script

Putting an Oilmonkey script on the shelf as a platform script requires three simple steps:

  • Using the hook
  • Local test
  • Update the extended list

Using the hook

When any page is opened, the platform runs the added extension. So what if you just want to do something on the nuggets page?

The platform provides two routing-specific hooks:

  • onLoaded: Executes when opening the gold digging page
  • onRouteChange(prevRouterPathname, currentRouterPathname): Execute when switching between mining pages

There are generally the following scenarios:

  1. There is no need to open the gold digging page for some operations, some background operations, such as: automatic check-in, regular publication of articles.
  2. Only in the digging page for operation, can be usedonLoadedDo this while the page is open. Since the mining part of the page is using a single page route, the page will not be reloaded, utilizingonRouteChangeYou can capture the timing of switching between pages and perform operations when switching to a specified page.

Here’s an example:

(function () {
    // GM_xmlhttpRequest(...)
    alert("Background check"); // Every time you open a page, check to see if you checked in today, if the article was recommended on the first page...
    
    function isInProfilePage (pathname) {
        return /\/user\/(\d+)(? : \ | $) /.test(pathname);
    }
    return {
        onLoaded () {
            // Pop a prompt when entering the gold digging page
            alert("Welcome to nuggets.");
        },
        onRouteChange(prev, current) {
            // Switch from boiling point to personal home page
            if(! inProfilePage(prev) && inProfilePage(current)) { alert("Entered personal home page"); }},isOffShelf: new Date().valueOf() < 1638288000000 // Only run extensions until 2021-12-01
    }
})()
Copy the code

Maybe you’ve already made routing decisions in your code, and you can just leave the script as it is, without even returning anything.

Simply put, the Oilmonkey script can specify running sites via @include and @match, but extension Helper opens up all sites and also provides onLoaded and onRouteChange for nuggets range routing support.

There is also an additional property, isOffShelf: whether to run extensions that can be used for time-sensitive scenarios, such as timed events

Local test

Open the extensions market, load native code through “Add Local Extensions” at the top, and refresh the nuggets page to verify.

Update the extended list

1. Fork Script market repository Curly210102 / juejin-hancer-Extensions: Dig little Assistant Extensions Collection (github.com)

2. Add a directory under the Extensions directory and create an index.md file under the directory

-- Title: Extension name Description: Brief introduction Version: 0.0.1 rawURL: https://gitee.com/curlly-brackets/juejin-post-tracker/raw/main/main.user.js preview: /preview.pngAuthor: Indicates the name of the authorExtended instructions...Copy the code

Markdown YAML description:

  • title: Extension name
  • description: A brief introduction in one sentence
  • version: the version number
  • rawURL: An accessible link for the script code to be downloaded by the platform. If it is hosted on Github it is recommended to do Gitee synchronization and give gitee a link
  • preview: thumbnail introduction, put the image inpublicDirectory, or directly to the remote address
  • author: the author’s name

There is no configuration for user feedback, it is better to add some explanation in the body.

3. Add the new directory name to juejin. Extension. json and select the corresponding category to add.

{
  "activity": {
    "title": "Activity"."extensions": ["juejin-post-tracker"]},"efficient": {
    "title": "Efficiency tools"."extensions": []},"data": {
    "title": "Statistics"."extensions": []},"others": {
    "title": "Other"."extensions": []}}Copy the code

4. Check the effect

yarn
yarn dev
Copy the code

Submit PR, and it will be automatically put on the shelves after approval.

If you need to update the version, change the version in Markdown and submit PR.

How to develop extensions

It is recommended to develop the oil monkey script first and then connect to the platform after development.

For a full tutorial on oilmonkey script development, see juejin.

If you want to write using modern front-end technology, the create-TamperMonk-NPM (nPMjs.com) scaffolding is recommended to start your project. It supports modularization, ESNext, TypeScript, CSS Module, ESLint, and oil-monkey script development environment. It also supports automatic extraction of UserScript headers, which is a great tool for developing oil-Monkey scripts.

For projects launched using create-TamperMonkey, add export Default at the end of main.js if you want to use the platform-provided hooks.

export default {
    onLoaded () {},
    onRouteChange(){}};Copy the code

The last

👏 thank you for your feedback and suggestions. If you have any questions or suggestions, please leave them in the comments section or contact us directly on wechat (Juan_mao_mao).

🔥 also welcomes friends who love technology to contribute code and participate in project optimization.

  • Oil monkey script warehouse address
  • Expand the market warehouse address

Hope you have a good time and enjoy yourself